| 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** |
| 33 | function 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 ** |
| 52 | function onClickRPS(playerChoice) { |