Rock, paper, scissor exercise help

Hi I am doing the rock paper scissor exercise and I have been stuck on it for days! One of the instructions just isn’t going right and i’ve made sure it is correct and watched the hlp video and the video is the same and the code just doesn’t seem to work if it is inside the curly brackets like it is supposed to be. I have attached an image to show …

https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-functions/projects/rock-paper-scissors-javascript

When you say it’s not working, what do you mean? Are you getting an error message, or is the variable not logging the correct lower case version to the console? Essentially what is happening that makes you know it isn’t working?

Hi sorry my post was a bit vague … Its all showing blue which I am assuming is wrong … It works on it’s own but then when the rest of the code is added it has an error and I am just struggling to see what I am doing wrong! Thanks

In that screenshot, your if statement is outside of the function, therefore it will not be called when getUserChoice() is called, and also it cannot see userInput as that parameter is restricted to the scope of the function. Move that inside of the function by moving the } on line 3 to line 8 and see if that sorts the issue.

Hi thank you so much that has sorted the error message out! The text is still all blue instead of its usual red etc … does that matter so much or does that mean something still isn’t right?

Sometimes the Codecademy text editor just bugs out and does weird colours. As long as your code is doing what you expect it to do then that’s fine!

1 Like