Open
Conversation
EricFooSD
reviewed
Oct 22, 2021
EricFooSD
left a comment
There was a problem hiding this comment.
Overall nice job. Would you be able to try part 2 as well?
Comment on lines
+1
to
+7
| // this is a basic version of scissors paper stone // | ||
| // scissors beats paper // | ||
| // paper beats stone // | ||
| // stone beats scissors // | ||
| // if both parties choose the same object, it is a draw // | ||
| // user chooses input as scissors paper or stone // | ||
| // randomly return one of scissors paper or stone // |
Comment on lines
+9
to
+22
| var generateMove = function () { | ||
| // Generate random number between 1 and 3 // | ||
| var numPossibleMoves = 3; | ||
| var randomNum = Math.floor(Math.random() * numPossibleMoves) + 1; | ||
|
|
||
| // Return the word that corresponds to the relevant number // | ||
| if (randomNum == 1) { | ||
| return "scissors"; | ||
| } | ||
| if (randomNum == 2) { | ||
| return "paper"; | ||
| } | ||
| return "stone"; | ||
| }; |
There was a problem hiding this comment.
[Comment] Good job to separate out this function by itself.
| if (move == userMove) { | ||
| return `${standardMessage} <br> <br> It's a draw! Please play again.`; | ||
| } | ||
| // scissors beats paper // |
There was a problem hiding this comment.
[Comment] Nice comments to show what the code is doing
Comment on lines
+40
to
+50
| if (move == "stone" && userMove == "scissors") { | ||
| return `${standardMessage} <br> <br> You lost! Please play again.`; | ||
| } | ||
| // scissors beats paper // | ||
| if (userMove == "scissors" && move == "paper") { | ||
| return `${standardMessage} <br> <br> You won! Please play again.`; | ||
| } | ||
| // paper beats stone // | ||
| if (userMove == "paper" && move == "stone") { | ||
| return `${standardMessage} <br> <br> You won! Please play again.`; | ||
| } |
There was a problem hiding this comment.
[Suggestion]: You could have combined some of these IF conditions. Using || to combine all the losing cases. This would simplify your code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please fill out the survey before submitting the pull request. Thanks!
🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
How many hours did you spend on this assignment?
Please fill in one error and/or error message you received while working on this assignment.
What part of the assignment did you spend the most time on?
Comfort Level (1-5):
Completeness Level (1-5):
What did you think of this deliverable?
Is there anything in this code that you feel pleased about?