everyone. I am making a little experiment with Javascript. I would like to make a guessing game, where the user guesses a number from 0-100 and the computer tells him/her "too low", "too high", or "correct." However, I want this **to be rigged**. That is, the computer should choose the longest path possible for the user to get the answer right. For example:

1. I guess 10. Since there are approximately ninety numbers more than 10 but only 10 numbers less than 10, the computer would say "My number is more than that" (in order to prolong the game).
2. I then guess 80. The computer should say "My number is less than that."
3. So on, until there is only one possibility left, and the computer is forced to say I got the right answer.

Right now, I just randomly say "too low" or "too high" which is problematic. For example:

1. I say 50. The computer says "My number is more than that"
2. I say 25 (even though I know the number is more than 50). The computer says "My number is less than that" which implies that it is cheating.

How can I avoid this? The computer should prolong the game but not be illogical.

My ideas:

* Create a `minValue` and `maxValue` variable which keep track of the current bounds of the guess. Unfortunately, I'm not sure how to implement this well.
* Create an array with all the possible values that the computer could be thinking of. Every time the user guesses, remove the values that are no longer possible. Repeat until there is only one element left in the array.

The ideas are basically the same. However, I'm stuck on implementing them. Thank you in advance.

I would like some steps (or code) on how to implement these ideas in Javascript.

Jsfiddle (although it may not help much, there is little in it): <http://jsfiddle.net/prankol57/f4JWw/>