1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
min = 0; max = 100; notGuessed = 1; while (notGuessed++){guess = Math.round((min+max)/2); c = prompt("My Guess is "+guess+"... Yes(y), Higher(h), Lower(l)?"); if (c == 'y'){alert("Yay, only "+notGuessed+" tries.");notGuessed=0;}else if(c=="h"){min=guess;}else if(c=="l"){max=guess;}}

//or

min = 0; 
max = 100; 
notGuessed = 1; 
while (notGuessed++){
    guess = Math.round((min+max)/2); 
    c = prompt("My Guess is "+guess+"... Yes(y), Higher(h), Lower(l)?"); 
    if (c == 'y'){
        alert("Yay, only "+notGuessed+" tries.");
        notGuessed=0;
    }else if(c=="h"){
        min=guess;
    }else if(c=="l"){
        max=guess;
    }
}