-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtreasurehunt.js
More file actions
25 lines (22 loc) · 765 Bytes
/
Copy pathtreasurehunt.js
File metadata and controls
25 lines (22 loc) · 765 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
var treasure = Math.floor(Math.random() *11)
var bomb = Math.floor(Math.random() *11)
while (treasure === bomb) {
bomb = Math.floor(Math.random() *11)
}
console.log("treasure", treasure);
console.log("bomb", bomb);
const findtreasure = (n) =>{
if (n == treasure) {
document.getElementById(n).innerHTML="🌈"
document.getElementById("game-board").innerHTML='<img src="box.png" height="438px" width="344px"/>'
alert("You found the treasure!!! Enjoy")
}
else if (n === bomb) {
document.getElementById(n).innerHTML="☠"
document.getElementById("game-board").innerHTML='<img src="boom!.png" height="438px" width="344px"/>'
alert("Better luck next time!")
}
else {
document.getElementById(n).innerHTML="⏳"
}
}