Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
// noprotect
alert('think of a number between 1 and 63');
  var min = 0;
  var max = 64;
  var guess = (min+max)/2;
  var guesses = 5;
var comguess = prompt ('i guessed '+guess+' is it too High(H) too low (L) correct (C)');
  comguess=comguess.toUpperCase(); 
while (guesses!==0){
  
   if (comguess === 'H'){ 
  
    var max = (guess+max)/2; 
  
    var comguess = prompt ('I guessed '+max+' is it too High(H) too low (L) correct (C)');
  comguess=comguess.toUpperCase(); 
  
  }
  else if (comguess === 'L'){
  
      var min = (min+guess)/2;
   
      var comguess = prompt ('i guessed '+min+' is it too High(H) too low (L) correct (C)');
  comguess=comguess.toUpperCase(); 
  }
  else if (comguess === ''){
  
  var comguess = prompt ("could you please enter H C or L");
   }
  else if (comguess === 'C'){
  
   alert("i've won!");
   break;
   }
  
  else   {
    alert("you've cheated!");
  break;
    
 }
//to stop guessing 
  guesses--;
  //no crazy amount of guesses
}
  
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
Dasia2016pro
0viewers