|
<script>
//Math
//by Norman Duong
//10-10-07
/*introduce function
user input
if correct, next question
if incorrect, make question correct
repeat five times*/
alert("Five questions are asked. All must be correct or the equation will run again and again...");
var guess="";
var output=1;
var score=0
var response=0;
response=Math.floor(Math.random()*6)+1;
while(score!=5){
num=Math.floor(Math.random()*1000)*1
num1=Math.floor(Math.random()*1000)*1
var correct=num+num1;
alert("Question "+output);
guess=prompt("What is "+num+" + "+num1+" equal to?","");
if(guess==correct){
alert("You may commence.");
output++;
score++;
}
if(guess!=correct){
switch(response){
case 1:
alert("You fail.");
break;
case 2:
alert("You phail.");
break;
case 3:
alert("You tried and you failed miserably. The lesson of that is to never try.");
break;
case 4:
alert("That was a very bad reply.");
break;
case 5:
alert("What a noob. Your math skills suck.");
break;
case 6:
alert("Your math skills are pitiful. Your level of mathematical understanding is equivalent to a third grader.");
break;
}
}
}
alert("Congratulations! You've passed the test!");
</script>
|
|