Hello, I downloaded a math game but I want to add a timer to it, but Im noob and dont know where to start. I found a js code to make a timerm because im to noob to make one myself. I want to add it when you are responding to a math ecuation, it any 4 types +-*/.

I tried to open the external .js from root but no luck so I think I need to add it here? ... OK heres the deal after u press add for instance, I want to see a 30 sec timer decreasing, and when it goes to zero an alert pop up and ends the player from answering, thats all, I will try hard while I wait for a response thx


Code:


var start = 1 * 31;
Number.prototype.toMinutesAndSeconds = function() {
	var nbr = Math.floor(this / 60);
	return (nbr+":")+(((nbr=(this-(nbr*60)))<10)?"0"+nbr:nbr);
}
function display(seconds, output) {
	output.innerHTML = (--seconds).toMinutesAndSeconds();
	if(seconds > 0) {
		window.setTimeout(function(){display(seconds, output)}, 1000);
	} else {
		alert("SE ACABO TU TIEMPO!");
	}
}
display(start, document.getElementById("countdown"),'segundos ');










<!DOCTYPE html>
<html>


<head>




<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Anja Henseler -->
<!-- Web Site:  http://www.hens.com/binoculars -->



<!-- Begin
correct=0;
wrong=0;

function random(maxValue) {
day= new Date();
hour= day.getHours();
min=day.getMinutes();
sec=day.getSeconds();
mili=day.getTime()
return(((hour*3600)+(min*60)+(sec)+mili) % maxValue);
}
function ranom(maxValue) {
day= new Date();
mil=day.getTime();
return((mil) % maxValue);
}

function add() {
if(document.quizform.arithmetic[0].checked)
maxValue=10;
else {
if(document.quizform.arithmetic[1].checked)
maxValue=30;
else {
maxValue=60;
   }
}
numA=random(maxValue);
numB=ranom(maxValue);

numC=numA + numB;

Answer=window.prompt(  numA + "+"  + numB +  " = ", "");
ans();
alert('cayate!!!!');
}
function subtract() {
if(document.quizform.arithmetic[0].checked)
maxValue=10;
else
{if(document.quizform.arithmetic[1].checked)
maxValue=30;
else {
maxValue=60
   }
}
numA=random(maxValue);
numB=ranom(maxValue);
numC=numA - numB;
Answer=window.prompt(  numA + "-"  + numB+  " = ", 0);
ans()
}
function divide() {
if(document.quizform.arithmetic[0].checked)
maxValue=10;
else {
if(document.quizform.arithmetic[1].checked)
maxValue=30;
else {
maxValue=60
   }
}
numA=random(maxValue)+1;
numB=ranom(maxValue)+1;
numC=numA / numB;
numC=Math.round(numC)
window.alert("Please round your answer off:\n"
+".5 or higher rounds one number up\n"
+".4 or lower rounds one number down");
Answer=window.prompt(  numA + "/"  + numB +  " = ", 0);
ans()
}
function multiply() {
if(document.quizform.arithmetic[0].checked)
maxValue=10;
else {
if(document.quizform.arithmetic[1].checked)
maxValue=30;
else {
maxValue=60
   }
}
numA=random(maxValue);
numB=ranom(maxValue);
numC=numA * numB;
Answer=window.prompt(  numA + "*"  + numB +  " = ", 0);
ans();
}
function check() {
if ((correct+wrong) != 0) {
score = "" + ((correct / (correct + wrong)) * 100);
score = score.substring(0,4) + "%";
alert("YOUR SCORE:  " + score + "\n"
+ correct + " correct\n"
+ wrong + " incorrect")
}
else alert("You have not completed any exercises yet.");
}
function ans() {
if (Answer == numC) {
correct++;
msg = "Congratulations, your answer is correct.";
}
else {
wrong++;
msg = "Oops!  " + Answer + " is incorrect.\n\n"
+ "The correct answer was " +numC + ".";
   }
score = "" + ((correct / (correct + wrong)) * 100);
score = score.substring(0,4) + "%";
alert(msg + "\n\nYOUR SCORE:  " + score + "\n"
+ correct + " correct\n"
+ wrong + " incorrect")
}
//  End -->
</script>





<title>MEMO MATH TEST</title>
</head>




<body>

<div id="border2">
</div>


<div id="border">

<center>

<form name=quizform>
<input type=button value="add" onClick="add()">
<input type=button value="subtract" onClick="subtract()">
<input type=button value="multiply" onClick="multiply()">
<input type=button value="divide" onClick="divide()">
<br>
<br>
<input type="radio" name="arithmetic">Easy
<input type="radio" name="arithmetic" checked>Moderate
<input type="radio" name="arithmetic">Difficult
<br>
<br>
<input type=button value="Check Score" onClick="check()">
<input type=button value="Reset Score" onClick="javascript:correct=0;wrong=0;">
</form>
</center>

</div>




</body>







</html>