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

BeatThatProject (Winston) #141

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

Conversation

winstoncheong23
Copy link

Please fill out the survey before submitting the pull request. Thanks!

🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀

How many hours did you spend on this assignment?
4
Please fill in one error and/or error message you received while working on this assignment.
There was no output in between "submit" button presses.
What part of the assignment did you spend the most time on?
I spent the most time on creating the logic.
Comfort Level (1-5):
4
Completeness Level (1-5):
4
What did you think of this deliverable?
It is a good reflection of what was taught.
Is there anything in this code that you feel pleased about?
It works well.

if (gameMode == "WHO WON") {
if (Number(finalValuePlayerOne) > Number(finalValuePlayerTwo)) {
return `Player One's final value of ${finalValuePlayerOne} is larger than Player Two's final value of ${finalValuePlayerTwo}. <br><br>Player One wins!`;
} else {
Copy link

Choose a reason for hiding this comment

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

Unnecessary 'else' after 'return'.


if (gameMode == "PLAYER TWO GUESS MODE") {
var firstValue = input;
var myOutputValue = ``;
Copy link

Choose a reason for hiding this comment

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

'myOutputValue' is already defined.

}

if (gameMode == "PLAYER TWO GUESS MODE") {
var firstValue = input;
Copy link

Choose a reason for hiding this comment

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

'firstValue' is already defined.


gameMode = "PLAYER ONE GUESS MODE";

return (myOutputValue = `Player One has rolled ${playerOneDiceArray[0]} and ${playerOneDiceArray[1]}. <br> To choose ${playerOneDiceArray[0]} as the first value, submit "1" . <br> To choose ${playerOneDiceArray[1]} as the first value, submit "2".`);
Copy link

Choose a reason for hiding this comment

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

'myOutputValue' was used before it was defined.


gameMode = "PLAYER ONE GUESS MODE";

return (myOutputValue = `Player One has rolled ${playerOneDiceArray[0]} and ${playerOneDiceArray[1]}. <br> To choose ${playerOneDiceArray[0]} as the first value, submit "1" . <br> To choose ${playerOneDiceArray[1]} as the first value, submit "2".`);
Copy link

Choose a reason for hiding this comment

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

Return statement should not contain assignment.

@codeclimate
Copy link

codeclimate bot commented Aug 3, 2021

Code Climate has analyzed commit 08e561a and detected 12 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 4
Duplication 2
Bug Risk 4
Compatibility 1
Clarity 1

Note: there are 6 critical issues.

View more on Code Climate.

Copy link

@eddiejpot eddiejpot left a comment

Choose a reason for hiding this comment

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

Overall good job on the logic! Room for improvement would be to use more helper functions to keep the code in the main function clean :)

Comment on lines +1 to +2
//global variables
var gameMode = "PLAYER ONE ROLL MODE";

Choose a reason for hiding this comment

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

Would be good to comment out all the gameModes here for clarity :)

Comment on lines +12 to +15
var diceRoll1 = rollDice();
var diceRoll2 = rollDice();
var diceRoll3 = rollDice();
var diceRoll4 = rollDice();

Choose a reason for hiding this comment

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

Interesting choice of rolling the dice on page load.
However might be better to only rolling the dice when needed. Reason being our code has to be flexible for any changes (e.g. what if the player needs to roll 3 dices, what if there are more than 2 players)

Comment on lines +29 to +41
if (gameMode == "PLAYER ONE GUESS MODE") {
var firstValue = input;
var myOutputValue = ``;
if (firstValue == "1") {
finalValuePlayerOne = `${playerOneDiceArray[0]}${playerOneDiceArray[1]}`;
myOutputValue += `Player One's final value is ${finalValuePlayerOne}.`;
} else if (firstValue == "2") {
finalValuePlayerOne = `${playerOneDiceArray[1]}${playerOneDiceArray[0]}`;
myOutputValue += `Player One's final value is ${finalValuePlayerOne}.`;
}
gameMode = "PLAYER TWO ROLL MODE";
return myOutputValue;
}

Choose a reason for hiding this comment

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

You'll notice that in the the GUESS MODE gameMode. Player 1 and 2 's code are almost identical.
This is usually a signal to decompose the logic here into a separate function that can be used for player1 and player2.

Take a look at the reference solution for this exercise and how multiple helper functions are used
reference

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