Make your own free website on Tripod.com
 
Home
ActionScript
Blog

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Number Guesser

<script>
//number guesser
//CAtherine Casuat 10-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 too 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){
msg = "YOU WIN!!! \n";
msg += "It took you ";
msg += turns + "turns! ";
alert(msg);
} // end if
} // end while
</script>