-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (38 loc) · 1.12 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
<!doctype html5>
<html>
<head>
<title>Memory</title>
</head>
<body>
<label>Select Number to display</label>
<select id="numbers"><option value="5">5</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<div id="display"></div>
<label>Input numbers you see in sequence</label>
<textarea id="answer" rows=3></textarea>
<input type="submit" value="check" />
</body>
<script>
var data = []
const numSelect = document.querySelector('#numbers')
numSelect.addEventListener('change', (event)=>{
data = []
for(var num = 0; num < event.target.value; num++){
var item = Math.round(Math.random() * 100)
data.push(item)
setTimeout(() => {
document.querySelector('#display').innerText = item
}, 1000)
}
setTimeout(() => {
document.querySelector('#display').innerText = ''
}, 1000)
})
document.querySelector('input').addEventListener('click', (e) => {
document.querySelector('#answer').value = data.join(',')
})
</script>
</html>