-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
41 lines (33 loc) · 1.18 KB
/
script.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
41
document.addEventListener("DOMContentLoaded", function() {
var storedResult = localStorage.getItem("heavenOrNotResult");
if (storedResult) {
displayResult(storedResult);
}
document.getElementById("checkButton").addEventListener("click", function() {
var num = Math.round(Math.random() * 1000) / 1000
var result = num < 0.5 ? "Yes" : "No";
if (num == 0.690) {
result = "Absolutely"
}
if (num == 0.666) {
result = "GOD HATES YOU"
}
localStorage.setItem("heavenOrNotResult", result);
displayResult(result);
});
});
function displayResult(result) {
document.getElementById("checkButton").style.display = "none";
var resultText = document.getElementById("resultText");
resultText.style.display = "block";
resultText.textContent = result;
if (result === "Yes") {
resultText.style.color = "green";
} else if (result === "No") {
resultText.style.color = "red";
} else if (result === "GOD HATES YOU") {
resultText.style.color = "black";
} else {
resultText.style.color = "gold"
}
}