MCPcopy Create free account
hub / github.com/codemistic/Web-Development / showResult

Function showResult

Rock-Paper-Scissors-Game/script.js:33–49  ·  view source on GitHub ↗
(score, playerChoice, computerChoice)

Source from the content-addressed store, hash-verified

31
32// ** showResult updates the DOM to `You Win!` or `You Lose!` or `It's a Draw!` based on the score. Also shows Player Choice vs. Computer Choice**
33function showResult(score, playerChoice, computerChoice) {
34
35 const resultDiv = document.getElementById('result')
36 const handsDiv = document.getElementById('hands')
37 const playerScoreDiv = document.getElementById('player-score')
38
39 if(score == -1){
40 resultDiv.innerText = 'You Lose!'
41 }else if(score == 1){
42 resultDiv.innerText = 'You Win!'
43 }else{
44 resultDiv.innerText = 'Draw!'
45 }
46
47 handsDiv.innerText=`🧑‍🦰 ${playerChoice} vs 🤖 ${computerChoice}`
48 playerScoreDiv.innerText =` Your Score: ${scores['playerScore']}`
49}
50
51// ** Calculate who won and show it on the screen **
52function onClickRPS(playerChoice) {

Callers 1

onClickRPSFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected