File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1- const results = document . getElementById ( ' results' ) ;
2- const playerDisplay = document . getElementById ( ' player-display' ) ;
3- const computerDisplay = document . getElementById ( ' computer-display' ) ;
4- const scores = document . getElementById ( ' scores' )
1+ const results = document . getElementById ( " results" ) ;
2+ const playerDisplay = document . getElementById ( " player-display" ) ;
3+ const computerDisplay = document . getElementById ( " computer-display" ) ;
4+ const scores = document . getElementById ( " scores" ) ;
55const options = [ "rock" , "paper" , "scissors" ] ;
66
77let result ;
@@ -27,17 +27,20 @@ function startGame(playerChoice) {
2727 }
2828 results . textContent = result ;
2929 playerDisplay . textContent = `Player Chose ${ playerChoice } ` ;
30- computerDisplay . textContent = `Computer Chose ${ computerChoice } ` ;
30+ computerDisplay . textContent = `Computer Chose ${ computerChoice } ` ;
3131
32- switch ( result ) {
32+ results . classList . remove ( "greenText" , "redText" )
33+ switch ( result ) {
3334 case "You Win!!" :
3435 playerScore += 1 ;
3536 scores . textContent = `Player:${ playerScore } - Computer:${ computerScore } ` ;
37+ results . classList . add ( "greenText" )
3638 break ;
3739
3840 case "You Lose" :
3941 computerScore += 1 ;
4042 scores . textContent = `Player:${ playerScore } - Computer:${ computerScore } ` ;
43+ results . classList . add ( "redText" )
4144 break ;
4245 }
4346}
Original file line number Diff line number Diff line change @@ -43,3 +43,11 @@ body {
4343 text-align : center;
4444 font-size : 5rem ;
4545}
46+
47+ .greenText {
48+ color : hsl (120 , 100% , 25% );
49+ }
50+
51+ .redText {
52+ color : hsl (0 , 100% , 50% );
53+ }
You can’t perform that action at this time.
0 commit comments