-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
63 lines (48 loc) · 1.55 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var opreators = ['+','-','*','/'];
//var opindex = Math.random()*4; //good that your rnum2 cannot be zero
//var operator = ops[opindex];
var randomIndex = Math.floor(Math.random() * opreators.length);
var randomOps = opreators[randomIndex];
function New(){
num1=document.getElementById("num1");
num2=document.getElementById("num2");
ops=document.getElementById("operator")
var question=document.getElementById("question")
rnum1 = Math.floor((Math.random()*10)+1);
rnum2 = Math.floor((Math.random()*10)+1);
var randomIndex = Math.floor(Math.random() * opreators.length);
var randomOps = opreators[randomIndex];
num1.innerHTML=rnum1
ops.innerHTML=randomOps
num2.innerHTML=rnum2
var answer= ops.innerHTML
console.log(answer)
if(answer=="+"){
CompAnswer=rnum1+rnum2
}
if(answer=="/")
{
CompAnswer=rnum1/rnum2
}
if(answer=="*"){
CompAnswer=rnum1*rnum2
}
if(answer=="-")
{
CompAnswer=rnum1-rnum2
}
console.log(CompAnswer)
var useranswer= prompt("Enter Your Answer For " +rnum1+answer+rnum2)
if(CompAnswer==useranswer){
alert("Correct Answer")
}
if(CompAnswer!=useranswer){
alert("Wrong Answer \n Coorect Answer : " + CompAnswer )
}
}
// TODO add service worker code here
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('service-worker.js')
.then(function() { console.log('Service Worker Registered'); });
};