Skip to content

SPS_Basics-11-5#346

Open
Deefei wants to merge 1 commit intorocketacademy:mainfrom
Deefei:main
Open

SPS_Basics-11-5#346
Deefei wants to merge 1 commit intorocketacademy:mainfrom
Deefei:main

Conversation

@Deefei
Copy link

@Deefei Deefei commented Oct 20, 2021

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

@Deefei Deefei changed the title Add files via upload Dee_SPS_Basics-11-5 Oct 20, 2021
@Deefei Deefei changed the title Dee_SPS_Basics-11-5 SPS_Basics-11-5 Oct 20, 2021
Copy link

@Ennnm Ennnm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good use of functions

Comment on lines +7 to +8
console.log("random guess generated by Computer:");
console.log(randomSPS);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 console logs to check flow and values

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!`;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice simplifying the draw case

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well named variables

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.

2 participants