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

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Exercise 4

<script>
//Math problems
//Catherine Casuat 10-18-07

var question = "";
var answer = 0;
var correct = "";
var number1 = "";
var number2 = "";
var i = 0;
var answer= "";

for (i = 1; i<5 ; i++)
{

number1 = Math.floor(Math.random() * 10)+1;
number2 = Math.floor(Math.random() * 10)+1;
correct = number1 + number2;

while (answer != correct)
{
answer=prompt("What is "+number1+" plus "+number2+" ?");

answer = eval(answer);

if (answer == correct)
{
alert("Awesome. You're correct.");
}//end if

else
alert("Wrong.");

}//end while
}// end for
alert ("Congrats. You passed.");

answer = prompt("Play gagain?", "YES");
answer = answer.toUpperCase();
</script>