Skip to content

Commit

Permalink
Merge pull request #3827 from meetarora10/tie-branch
Browse files Browse the repository at this point in the history
Display the number of ties in rock paper scissors game.
  • Loading branch information
kunjgit authored May 28, 2024
2 parents d0f0576 + e260709 commit c402565
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Games/Rock_Paper_Scissors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ <h1>Rock Paper Scissors</h1>
<div id="resultPanel">
<p id="resultText">Make your move!</p>
<p id="scoreText">Score: You - 0 | Computer - 0</p>
<p id="tieText">Ties: 0</p>
</div>
<div id="computerPanel">
<p>Computer's Choice:</p>
Expand Down
4 changes: 4 additions & 0 deletions Games/Rock_Paper_Scissors/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var choices = ["rock", "paper", "scissors"];
var userScore = 0;
var computerScore = 0;
var tieScore = 0;
let isAutoPlaying=false;
let id;

Expand Down Expand Up @@ -46,12 +47,15 @@ function updateScore(result) {
userScore++;
} else if (result === "Computer wins!") {
computerScore++;
}else{
tieScore++;
}
updateResult();

}
function updateResult(){
scoreText.textContent = "Score: You - " + `${userScore}` + " | Computer - " + `${computerScore}`;
tieText.textContent = "Ties: "+`${tieScore}`;
}
function play(userChoice) {
var computerChoice = getComputerChoice();
Expand Down
3 changes: 3 additions & 0 deletions Games/Rock_Paper_Scissors/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ button{
#scoreText {
font-size: 18px;
}
#tieText{
font-size: 18px;
}
.btn{
color: white;
background: transparent;
Expand Down
Binary file modified assets/images/Rock_Paper_Scissors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c402565

Please sign in to comment.