Open
Conversation
Ennnm
reviewed
Oct 21, 2021
Ennnm
left a comment
There was a problem hiding this comment.
well done! Good job at using global variables , pseudocode and console logs.
For future improvement, you can try to find areas where you've duplicated code and make functions of them for reuse 👍
Comment on lines
+62
to
+72
| var randomSPSoutput = function () { | ||
| var randomise = Math.floor(Math.random() * 3); | ||
|
|
||
| if (randomise == 0) { | ||
| return "scissors"; | ||
| } | ||
| if (randomise == 1) { | ||
| return "paper"; | ||
| } | ||
| return "stone"; | ||
| }; |
Comment on lines
+7
to
+8
| console.log("random guess generated by Computer:"); | ||
| console.log(randomSPS); |
Comment on lines
+13
to
+18
| if (input == randomSPS) { | ||
| userAttempt += 1; | ||
| userWinningPercentage = (userWin / userAttempt) * 100; | ||
| userWinningPercentage = userWinningPercentage.toFixed(1); | ||
| return `It's a tie! <br> <br> Your guess: ${input}; <br> Computer guess: ${randomSPS} <br><br> You have attempted ${userAttempt} times and won ${userWin} times (${userWinningPercentage}%) ! <br><br> Type "scissors", "paper" or "stone" to play another round!`; | ||
| } |
Comment on lines
+20
to
+23
| // You win, | ||
| // IF input == scissors && random output == paper | ||
| // OR input == paper && random output == rock | ||
| // OR input == rock && random output == scissors |
There was a problem hiding this comment.
good use of pseudo code to set out conditions
Comment on lines
+30
to
+33
| userAttempt += 1; | ||
| userWin += 1; | ||
| userWinningPercentage = (userWin / userAttempt) * 100; | ||
| userWinningPercentage = userWinningPercentage.toFixed(1); |
There was a problem hiding this comment.
could be refactored into a function that takes in userAttempt and userWin to return winning percentage
as this code is reused for draw, win and loss conditions
Comment on lines
+1
to
+3
| var userWin = 0; | ||
| var userAttempt = 0; | ||
| var userWinningPercentage = 0; |
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?
: 5 hours+
Please fill in one error and/or error message you received while working on this assignment.
: script.js:7 Uncaught ReferenceError: randomSPSnum is not defined
at randomSPSoutput (script.js:7)
at main (script.js:21)
at HTMLButtonElement. (index.html:69)
What part of the assignment did you spend the most time on?
: was stucked at the beginning when i keep getting the same random output number
Comfort Level (1-5): 1
Completeness Level (1-5): 3
What did you think of this deliverable?
: should be okay, but i only did the base
Is there anything in this code that you feel pleased about?
: happy that my code work out eventually