0% found this document useful (0 votes)
8 views1 page

Currency

This document is an HTML page for a Rock Paper Scissors game. It includes a JavaScript function that determines the outcome of the game based on the player's choice and the computer's random selection. The results are displayed on the webpage after each game round.

Uploaded by

danglongpct2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Currency

This document is an HTML page for a Rock Paper Scissors game. It includes a JavaScript function that determines the outcome of the game based on the player's choice and the computer's random selection. The results are displayed on the webpage after each game round.

Uploaded by

danglongpct2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rock Paper Scissors</title>
<script>
function playGame(playerChoice) {
const choices = ["keo", "bua", "bao"];
const computerChoice = choices[Math.floor(Math.random() *
choices.length)];

let result = "";


if (playerChoice === computerChoice) {
result = "It's a tie!";
} else if (
(playerChoice === "keo" && computerChoice === "bao") ||
(playerChoice === "bua" && computerChoice === "keo") ||
(playerChoice === "bao" && computerChoice === "bua")
) {
result = "You win!";
} else {
result = "You lose!";
}

document.getElementById("result").innerText = `Computer chose: $


{computerChoice}. ${result}`;
}
</script>
</head>
<body>
<h2>Rock Paper Scissors</h2>
<button onclick="playGame('keo')">✂️ Kéo</button>
<button onclick="playGame('bua')">🪨 Búa</button>
<button onclick="playGame('bao')">📄 Bao</button>
<p id="result"></p>
</body>
</html>

You might also like