Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Minor cleanup #2

wants to merge 2 commits into from

Conversation

badsketch
Copy link

Just some minor nits 🙂

}
else if (playerChoice == 'rock' && cpuChoice === 'paper') {
winnerOfRound = 'You lose! Paper beats rock!';
console.log(winnerOfRound);
cpuButtonHighlight(cpuPaper);
cpuIncrementScore(cpuScore, cpuScoreElement);
Copy link
Author

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);
Copy link
Author

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) {
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant