<html>
<head>
<title>Number Guesser</title>
<script>
var guess = 50;
var target = 0;
var turns = 0;
var msg = "";
target = Math.floor(Math.random() * 100) + 1;
guess = eval(prompt("What is your guess?", guess));
while (guess != target){
turns++;
if (guess > target){
guess = eval(prompt (turns + ". Too high!! Next guess?", guess));
}
if (guess < target){
guess = prompt (turns + ". Too low!! Next guess?", guess);
}
if (guess == target){
msg = "YOU WIN!!! \n";
msg += "It took you ";
msg += turns + " turns! ";
alert (msg);
}
}
</script>
</head>