How to create a multiple number guessing game with Javascript/PHP/any progamming language? [closed]

I want to create and understand how to create a multiple number guessing game like this: Number Guessing Game Example

I want to understand the algorithm of this program. Like how this program randomly generate a multiple number. And then, how do I know the random number that will be generated from this game. Like, how can I know what number will come out.