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

Function getResult

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

Source from the content-addressed store, hash-verified

10
11
12function 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**
33function showResult(score, playerChoice, computerChoice) {

Callers 1

onClickRPSFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected