-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor cleanup #2
base: main
Are you sure you want to change the base?
Conversation
} | ||
else if (playerChoice == 'rock' && cpuChoice === 'paper') { | ||
winnerOfRound = 'You lose! Paper beats rock!'; | ||
console.log(winnerOfRound); | ||
cpuButtonHighlight(cpuPaper); | ||
cpuIncrementScore(cpuScore, cpuScoreElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are global variables, so they don't need to be passed in as they're accessed directly.
} | ||
else if (playerChoice == 'rock' && cpuChoice === 'paper') { | ||
winnerOfRound = 'You lose! Paper beats rock!'; | ||
console.log(winnerOfRound); | ||
cpuButtonHighlight(cpuPaper); | ||
cpuIncrementScore(cpuScore, cpuScoreElement); | ||
return changeBannerText(winnerOfRound); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think best practice is that event handlers don't return a value
console.log('The function cpuIncrementScore() is now running....'); | ||
cpuScore++; | ||
cpuScoreElement.innerHTML = `Score: ${cpuScore}`; | ||
} | ||
function playerCPUDraw(playerScore, cpuScore) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to remove this function, since nothing needs to happen if there's a draw. It's implicit, but sometimes explicit is good too, like what you did here
Just some minor nits 🙂