Conversation
bwcee
left a comment
There was a problem hiding this comment.
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'; | |||
There was a problem hiding this comment.
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.
| var numUserWin = 0; | ||
| // track number of games user lost | ||
| var numUserLost = 0; | ||
| //track number of games user draws | ||
| var numUserDraw = 0; |
There was a problem hiding this comment.
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.
| 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; | ||
| }; |
There was a problem hiding this comment.
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'; | ||
|
|
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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...
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