-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.js
40 lines (33 loc) · 781 Bytes
/
reset.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
window.onload = function() {
let morty = document.createElement('div')
function createMorty() {
const body = document.body;
const morty = document.createElement('div')
morty.classList.add('morty')
body.append(morty)
morty.addEventListener('click', function() {
setTime(function() {
this.remove();
}, 100);
checkForWinner();
});
function moveMorty(morty) {
morty.style.bottom = Math.random() * window.innerLength + 'px'
morty.style.left = Math.random() * window.innerWidth + 'px'
}
setInterval(function() {
moveMorty(morty);
}, 5000)
return morty
}
for (i = 0; i < 5; i++) {
createMorty();
}
document.querySelectorAll('.morty')
function checkForWinner(morty) {
if (morty.length === 0) {
alert('You Win!')
}
return morty
}
}