| 10 | |
| 11 | |
| 12 | function getResult(playerChoice, computerChoice) { |
| 13 | // return the result of score based on if you won, drew, or lost |
| 14 | var score=0; |
| 15 | // All situations where human draws, set `score` to 0 |
| 16 | if(playerChoice === computerChoice){ |
| 17 | score = 0; |
| 18 | }else if(playerChoice==='Rock' && computerChoice==='Scissors'){ |
| 19 | score = 1 |
| 20 | }else if(playerChoice==='Paper' && computerChoice==='Rock'){ |
| 21 | score = 1 |
| 22 | }else if(playerChoice==='Scissors' && computerChoice==='Paper'){ |
| 23 | score = 1 |
| 24 | |
| 25 | }else{ |
| 26 | score = -1 |
| 27 | } |
| 28 | |
| 29 | return score |
| 30 | } |
| 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) { |