-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (24 loc) 路 893 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (24 loc) 路 893 Bytes
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
let numberToGuess = Math.round(Math.random() * 100);
let attempts = 0;
function guessNumber() {
attempts = attempts + 1;
displayAttempts.innerHTML = 'Versuche: ' + attempts;
if (numberToGuess == myNumber.value) {
headline.innerHTML = 'Du hast die Zahl gefunden!馃帀';
let jsConfetti = new JSConfetti();
jsConfetti.addConfetti();
setTimeout(() => {
headline.innerHTML = 'Errate die Zahl zwischen 0 und 100.';
numberToGuess = Math.round(Math.random() * 100);
attempts = 0;
displayAttempts.innerHTML = 'Versuche: ' + attempts;
}, 4000);
}
if (numberToGuess > myNumber.value) {
headline.innerHTML = 'Die gesuchte Zahl ist gr枚脽er.';
}
if (numberToGuess < myNumber.value) {
headline.innerHTML = 'Die gesuchte Zahl ist kleiner.';
}
myNumber.value = '';
}