Make your own free website on Tripod.com
SWAT My Welcome Of Doom to you!!!
  Javascript Actionscript Blog
  <script>
//NumberGuesser
//David Fang, 10/07
//The classic number guessing game
var guess=50;
var target=0;
var turns=0;
var msg="";
target= Math.floor(Math.random() * 100) +1;
//alert(target);
msg="I'm thinking of a number between 1 and 100. \n";
msg +="Guess my number, and I'll tell you if it's to high, \n";
msg +="too low, or correct. Try to guess in the fewest turns.";
alert(msg);
guess=eval(prompt("What is your guess?", guess));
while(guess !=target) {
turns++;
if(guess > target) {
guess=eval(prompt(turns + ". Too high!! Next guess?", guess));
} // end if
if(guess < target) {
guess=prompt(turns + ". Too low!! Next guess?", guess);
} // end if
if(guess == target) {
msg="YOU WIN!!! \n";
msg +="It took you ";
msg += turns + " turns! ";
alert(msg);
} // end if
} // end while
</script>

Links

1. SLHS

2. SLHSXC

3. JMMS

Contact me

Class links

Computer Science

Five Classmates

1. Julio Maravilla

2. Norman Duong

3. Huy Vo

4. Titus Green

5. Jack Li

 
 
 
 
 
 
 
 
Home Product Contact order