-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
27 lines (23 loc) · 1023 Bytes
/
app.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
function playButton() {
var userInput = parseInt(document.getElementById("number").value);
var randomValue = parseInt(Math.random() * 10 + 1);
if (userInput <=10) {
document.getElementById("bot_number").value = randomValue;
if (userInput == randomValue) {
document.getElementById("result").innerHTML = "👏 Hooray! You won the game!"
document.body.style.backgroundColor = "#edffed";
} else {
document.getElementById("result").innerHTML = "😔 You lose the game, better luch next time."
document.body.style.backgroundColor = "#ffeded";
}
} else {
document.getElementById("result").innerHTML = "Please enter a valid number between 1 and 10!"
}
}
function resetButton() {
var userInput = document.getElementById("number");
var result = document.getElementById("result");
userInput.value = "0"
result.innerHTML = "";
document.body.style.backgroundColor = "#f3edff";
}