-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (48 loc) · 1.34 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js</title>
</head>
<body>
<br>
<br>
<br>
<center>
<h1 id="demo">
<script>
var numOne =Math.floor(Math.random( )*10) + 4;
var numTwo =Math.floor(Math.random( )*10) + 4;
document.write(numOne + " + " + numTwo);
var correctAnswer = numOne + numTwo;
</script>
</h1>
<p>Hello, Please enter Your answer</p>
<input type="text" id="input">
<button type="button" onclick="myFunction();">Click Me</button>
<button type="button" onclick="reloadBtn();">Get A New Card</button>
<p id="output"></p>
</center>
<script>
function myFunction() {
var input = document.getElementById('input').value;
isNaN(input);
if (isNaN(input)) {
document.getElementById('output').innerHTML = ("Hey! that's not A number" + " : " + input);
} else if (input == correctAnswer) {
document.getElementById('output').innerHTML = ('Correct');
} else {
document.getElementById('output').innerHTML = ('Wrong try Again !');
}
}
function reloadBtn() {
document.getElementById('output').innerHTML = "";
document.getElementById('input').value ="";
numOne =Math.floor(Math.random( )*10) + 4;
numTwo =Math.floor(Math.random( )*10) + 4;
document.getElementById('demo').innerHTML =numOne + " + " + numTwo;
correctAnswer = numOne + numTwo;
}
</script>
</body>
</html>