Skip to content

nat 11-6 part 2#345

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

nat 11-6 part 2#345
natsadiq wants to merge 1 commit intorocketacademy:mainfrom
natsadiq:main

Conversation

@natsadiq
Copy link

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

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

How many hours did you spend on this assignment? 1.5

Please fill in one error and/or error message you received while working on this assignment. unexpected end of input

What part of the assignment did you spend the most time on? trying to ensure the user name function works

Comfort Level (1-5): 1

Completeness Level (1-5): 3

What did you think of this deliverable? interesting add to the code

Is there anything in this code that you feel pleased about? glad that it's coming together but it's not there yet

Copy link

@bwcee bwcee left a comment

Choose a reason for hiding this comment

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

Good attempt Natasha : )

  • demonstrated understanding of use of global variables to create variable value persistency over lifecycle of program
  • good attempt to make use of game mode to decide whether to accept input as user name or to accept it as a symbol user is playing
  • generally kept to javascript naming convention and choice of variable/ function names were clear and made the code easy to read and understand

A few bugs kept your code from running. Will send you a revised script via Slack so the code will run.

You only coded for case of when user inputs scissors for now and not for paper or stone.
You could search for Sherman's code in rocketacademy/basics-scissors-paper-stone pull requests section for reference on how to fully code the different possibilities.

@@ -1,4 +1,79 @@
//include current gamemode
var currentGameMode = 'insert username to begin';
Copy link

Choose a reason for hiding this comment

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

Dun actually need this variable. Can test if userName=="" instead to decide if should assign input as userName instead of using it as input to play scissors paper stone.

Comment on lines +6 to +10
var numUserWin = 0;
// track number of games user lost
var numUserLost = 0;
//track number of games user draws
var numUserDraw = 0;
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 global variables to keep track of different parameters. Only required to keep track of numUserWin, but implementation of numUserLost and numUserDraw shows understanding of concept of variable value persistency over a program's lifecycle.

Comment on lines 12 to 25
var main = function (input) {
var myOutputValue = 'hello world';
// first game mode is when username is keyed in
if (currentGameMode == "insert username to begin") {
userName = input;
currentGameMode = "commence scissors paper stone game";
myOutputValue = "hello " + input + " you can now begin the game.";
// second game mode is when username is not keyed in
} else if (!input) {
currentGameMode = "insert username to begin";
userName = !input;
myOutputValue = "error please insert username to begin";
}
return myOutputValue;
};
Copy link

Choose a reason for hiding this comment

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

There is another main() from line 54 onwards below. There cannot be 2 functions with the same name. When main() is invoked, computer will not know which main() to use.
The contents of main() from line 54 below should be included in this main().

var SCISSORS = 'scissors';
var PAPER = 'paper';
var STONE = 'stone';

Copy link

Choose a reason for hiding this comment

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

Should name these variables as below to follow javascript naming convention of camelCase.
var scissors ="scissors";
var paper = "paper";
var stone = "stone";

}

// invoke functions
var computerChoice = genComputerChoice(getRandomInteger());
Copy link

Choose a reason for hiding this comment

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

var computerChoice needs to be inside main() so it is called ea time main() is called, so a diff computerChoice can be created ea time. Otherwise, computerChoice is only created once, and computer will always play the same symbol...

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