scissors paper stone basics 11-5#344
Open
sinyuenn wants to merge 2 commits intorocketacademy:mainfrom
Open
Conversation
Ennnm
reviewed
Oct 20, 2021
Ennnm
left a comment
There was a problem hiding this comment.
well done, control flow is quite clear, used functions to rollScissorPaperStone.
could try using more functions in the future to further simplify code in the main function ⭐
Comment on lines
+2
to
+16
| var rollScissorPaperStone = function () { | ||
| var randomDecimal = Math.random() * 3; | ||
| var randomInteger = Math.floor(randomDecimal); | ||
| var signRolled = 0; | ||
| if (randomInteger == 0) { | ||
| signRolled = `scissors`; | ||
| } | ||
| if (randomInteger == 1) { | ||
| signRolled = `paper`; | ||
| } | ||
| if (randomInteger == 2) { | ||
| signRolled = `stone`; | ||
| } | ||
| return signRolled; | ||
| }; |
There was a problem hiding this comment.
gd job abstracting this out into a function
| const signs = [`scissors`, `paper`, `stone`]; | ||
| var gamesCount = 0; | ||
| var userWonCount = 0; | ||
| var CompWonCount = 0; |
There was a problem hiding this comment.
should follow camel-case convention just like your other variables
| return signRolled; | ||
| }; | ||
|
|
||
| const signs = [`scissors`, `paper`, `stone`]; |
There was a problem hiding this comment.
Nice trying this out in advance, could have been used for assigning signedRolled in rollScissorsPaper stone function
| var main = function (input) { | ||
| var myOutputValue = 'hello world'; | ||
| var randomSign = rollScissorPaperStone(); | ||
| console.log(`computer generated ${randomSign}`); |
| var myOutputValue = 'hello world'; | ||
| var randomSign = rollScissorPaperStone(); | ||
| console.log(`computer generated ${randomSign}`); | ||
| var myOutputValue = `Uh oh, I cannot read your message. <br> |
Comment on lines
+31
to
+35
| if (input == randomSign) { | ||
| gamesCount += 1; | ||
| drawCount += 1; | ||
| myOutputValue = `You chose ${input}. <br> The computer chose ${randomSign}. <br> You drawed ${drawCount} times. <br> Type "scissors" "paper" or "stone" to play another round!`; | ||
| } |
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? 2 hrs
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):3
Completeness Level (1-5):3
What did you think of this deliverable?could be better
Is there anything in this code that you feel pleased about?