-
Notifications
You must be signed in to change notification settings - Fork 3
/
Multiplication.html
71 lines (67 loc) · 2.15 KB
/
Multiplication.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiplication Flashcard Game</title>
<style>
html {
height: 100%;
}
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 99%;
background-color: #f0f0f0;
margin: 0;
}
.game-container {
text-align: center;
background: #fff;
padding: 2em;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
height:70%;
margin:2em;
}
.flashcard {
font-size: 40vmin;
align-items: center;
}
</style>
</head>
<body>
<div class="game-container">
<div class="flashcard" id="flashcard">
</div>
</div>
<script>
let num1, num2, correctAnswer;
question = false;
function generateQuestion() {
if (!question) {
num1 = Math.floor(Math.random() * 9) + 4;
num2 = Math.floor(Math.random() * 9) + 4;
rCr = Math.floor(Math.random() * 200) + 1;
rCb = Math.floor(Math.random() * 200) + 1;
rCg = Math.floor(Math.random() * 200) + 1;
correctAnswer = num1 * num2;
document.getElementById('flashcard').innerText = num1 + "x" + num2;
document.getElementById('flashcard').style.color = "rgb("+rCr+","+rCb+","+rCg+")";
question = true;
}
else {
document.getElementById('flashcard').innerText = correctAnswer;
question = false;
}
//document.getElementById('flashcard').innerText = `${num1} x ${num2} = ?`;
}
document.getElementById('flashcard').addEventListener('click', function() {
generateQuestion();
});
generateQuestion();
</script>
</body>
</html>