Please help me with this. I am not understanding what to do. Please fix the code to the display all contents of the image below. I DONT NEED IT TO DISPLAY ALL. ALL CONTENTS OF THE IMAGES ARE SHOWING EXECPT FOR WHEN IT GIVES THE RESULTS OF THE GAMES AT THE BOTTOM (e.g. Player 2 wins, etc.) HTML: Task 5 Rock, Paper, Scissors Play JAVASCRIPT: // Global variables to keep track of wins and losses let player1Wins = 0; let player2Wins = 0; let ties = 0; function playGame() { // Generate random numbers for player and computer const playerChoice = Math.floor(Math.random() * 3) + 1; const computerChoice = Math.floor(Math.random() * 3) + 1; // Convert the random numbers to text choices let playerTextChoice; let computerTextChoice; if (playerChoice === 1) { playerTextChoice = 'ROCK'; } else if (playerChoice === 2) { playerTextChoice = 'SCISSORS'; } else { playerTextChoice = 'PAPER'; } if (computerChoice === 1) { computerTextChoice = 'ROCK'; } else if (computerChoice === 2) { computerTextChoice = 'SCISSORS'; } else { computerTextChoice = 'PAPER'; } // Update the paragraph with player and computer choices const myData = document.getElementById('mydata'); myData.innerHTML = `Player 1 plays ${playerTextChoice} and Player 2 plays ${computerTextChoice}`; // Determine the winner let winner; if (playerChoice === computerChoice) { winner = 'Tie'; ties++; } else if (playerChoice === 1 && computerChoice === 3) { winner = 'Player 1 Wins!'; player1Wins++; } else if (playerChoice === 2 && computerChoice === 1) { winner = 'Player 1 Wins!'; player1Wins++; } else if (playerChoice === 3 && computerChoice === 2) { winner = 'Player 1 Wins!'; player1Wins++; } else { winner = 'Player 2 Wins!'; player2Wins++; } // Display the winner using an alert if it's not a tie if (winner !== 'Tie') { alert(winner); } else { alert('Tie!'); } // Display the tally alert(`Player 1 Wins: ${player1Wins}\nPlayer 2 Wins: ${player2Wins}\nTies: ${ties}`); }
Please help me with this. I am not understanding what to do. Please fix the code to the display all contents of the image below. I DONT NEED IT TO DISPLAY ALL. ALL CONTENTS OF THE IMAGES ARE SHOWING EXECPT FOR WHEN IT GIVES THE RESULTS OF THE GAMES AT THE BOTTOM (e.g. Player 2 wins, etc.) HTML: Task 5 Rock, Paper, Scissors Play JAVASCRIPT: // Global variables to keep track of wins and losses let player1Wins = 0; let player2Wins = 0; let ties = 0; function playGame() { // Generate random numbers for player and computer const playerChoice = Math.floor(Math.random() * 3) + 1; const computerChoice = Math.floor(Math.random() * 3) + 1; // Convert the random numbers to text choices let playerTextChoice; let computerTextChoice; if (playerChoice === 1) { playerTextChoice = 'ROCK'; } else if (playerChoice === 2) { playerTextChoice = 'SCISSORS'; } else { playerTextChoice = 'PAPER'; } if (computerChoice === 1) { computerTextChoice = 'ROCK'; } else if (computerChoice === 2) { computerTextChoice = 'SCISSORS'; } else { computerTextChoice = 'PAPER'; } // Update the paragraph with player and computer choices const myData = document.getElementById('mydata'); myData.innerHTML = `Player 1 plays ${playerTextChoice} and Player 2 plays ${computerTextChoice}`; // Determine the winner let winner; if (playerChoice === computerChoice) { winner = 'Tie'; ties++; } else if (playerChoice === 1 && computerChoice === 3) { winner = 'Player 1 Wins!'; player1Wins++; } else if (playerChoice === 2 && computerChoice === 1) { winner = 'Player 1 Wins!'; player1Wins++; } else if (playerChoice === 3 && computerChoice === 2) { winner = 'Player 1 Wins!'; player1Wins++; } else { winner = 'Player 2 Wins!'; player2Wins++; } // Display the winner using an alert if it's not a tie if (winner !== 'Tie') { alert(winner); } else { alert('Tie!'); } // Display the tally alert(`Player 1 Wins: ${player1Wins}\nPlayer 2 Wins: ${player2Wins}\nTies: ${ties}`); }
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please help me with this. I am not understanding what to do. Please fix the code to the display all contents of the image below. I DONT NEED IT TO DISPLAY ALL. ALL CONTENTS OF THE IMAGES ARE SHOWING EXECPT FOR WHEN IT GIVES THE RESULTS OF THE GAMES AT THE BOTTOM (e.g. Player 2 wins, etc.)
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Task 5 </title>
<link href="style.css" type="text/css" rel="stylesheet">
<script src="task5.js"></script>
</head>
<body>
<div id="box">
<p style="font-family: monospace;" class="newdata"> Rock, Paper, Scissors </p>
<p></p>
<button id="button" onclick="playGame();"> Play </button>
<p></p>
<p style="font-family: monospace;" id="mydata" class="newdata"></p>
</div>
</body>
</html>
JAVASCRIPT:
// Global variables to keep track of wins and losses
let player1Wins = 0;
let player2Wins = 0;
let ties = 0;
function playGame() {
// Generate random numbers for player and computer
const playerChoice = Math.floor(Math.random() * 3) + 1;
const computerChoice = Math.floor(Math.random() * 3) + 1;
// Convert the random numbers to text choices
let playerTextChoice;
let computerTextChoice;
if (playerChoice === 1) {
playerTextChoice = 'ROCK';
} else if (playerChoice === 2) {
playerTextChoice = 'SCISSORS';
} else {
playerTextChoice = 'PAPER';
}
if (computerChoice === 1) {
computerTextChoice = 'ROCK';
} else if (computerChoice === 2) {
computerTextChoice = 'SCISSORS';
} else {
computerTextChoice = 'PAPER';
}
// Update the paragraph with player and computer choices
const myData = document.getElementById('mydata');
myData.innerHTML = `Player 1 plays ${playerTextChoice} and Player 2 plays ${computerTextChoice}`;
// Determine the winner
let winner;
if (playerChoice === computerChoice) {
winner = 'Tie';
ties++;
} else if (playerChoice === 1 && computerChoice === 3) {
winner = 'Player 1 Wins!';
player1Wins++;
} else if (playerChoice === 2 && computerChoice === 1) {
winner = 'Player 1 Wins!';
player1Wins++;
} else if (playerChoice === 3 && computerChoice === 2) {
winner = 'Player 1 Wins!';
player1Wins++;
} else {
winner = 'Player 2 Wins!';
player2Wins++;
}
// Display the winner using an alert if it's not a tie
if (winner !== 'Tie') {
alert(winner);
} else {
alert('Tie!');
}
// Display the tally
alert(`Player 1 Wins: ${player1Wins}\nPlayer 2 Wins: ${player2Wins}\nTies: ${ties}`);
}

Transcribed Image Text:Tiel
file://
Rock, Paper, Scissors
Play
When you close the alert, you should see something that looks like this:
Rock, Paper, Scissors
Play
Player 1 plays PAPER and Player 2 plays PAPER
No winner this round
If there is a winner, however, you should see something like this:
Rock, Paper, Scissors.
Play
Player 1 plays SCISSORS and Player 2 plays ROCK
Player 2 wins
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education