Tanuki Game
Try your luck and see if you can keep your money!
<!DOCTYPE html>
<html>
<head>
<title>Tanuki Game</title>
</head>
<body onLoad="startGame()">
<h1>Tanuki Game</h1>
<p>Try your luck and see if you can keep your money!</p>
<button id="playBtn">Play</button>
<p id="result"></p>
<script>
function startGame() {
document.getElementById("playBtn").addEventListener("click", playTanuki);
}
function playTanuki() {
var randNum = Math.floor(Math.random() * 10) + 1; // generate random number between 1 and 10
if (randNum == 1) {
document.getElementById("result").innerHTML = "Oh no! The tanuki took all your money! 😭";
} else {
document.getElementById("result").innerHTML = "Phew! You get to keep your money! 😅";
}
}
</script>
</body>
</html>