Page 400 - Web_Application_v2.0_C12_Fb
P. 400
.choices {
DISPLAY: flex;
justify-content: center;
margin: 10px 0;
}
.score {
font-size: 32px;
font-weight: bold;
margin-top: 10px;
}
.result {
font-size: 32px;
font-weight: bold;
display: flex;
flex-direction: column;
align-items: center;
}
.result div {
display: flex;
justify-content: center;
margin-top: 10px;
}
.result-img {
width: 200px;
}
File3: Script.js
let won = 0, lost = 0, draw = 0;
function play(userChoice) {
let choices = [‘rock’, ‘paper’, ‘scissors’];
let computerChoice = choices[Math.floor(Math.random() * 3)];
let resultText = “”;
if (userChoice === computerChoice) {
draw++;
resultText = “It’s a Draw!”;
}
else if ((userChoice === “rock” && computerChoice === “scissors”) ||(userChoice
=== “paper” && computerChoice === “rock”) ||(userChoice === “scissors” &&
computerChoice === “paper”)) {
won++;
resultText = `You Win! ${userChoice.charAt(0).toUpperCase() + userChoice.
slice(1)} beats ${computerChoice}!`;
}
398 Touchpad Web Applications (Ver. 2.0)-XII

