Rock, Papers, Scissors project issues with running code

I’m doing the Rock, Papers, Scissors project under the Learn Javascript module.
I’m having issues when I save my code, it gives me the following error at line 35:
if(userChoice === ‘rock’) {
ReferenceError: userChoice is not defined
at Object. (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:27:4)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3

I followed the directions very carefully, watched the expert video about this (who followed the exact instructions and didn’t have the error I did), and tried modifying the code to something it might understand like getUserChoice as that was a function it had me create. No where does it say create a function specifically for userChoice. I also had a similar problem with computerChoice. Any tips or ideas on this would be greatly appreciated!

The first thing to do is check spelling. Where is userChoice defined? Somewhere in the code? Or as a formal parameter of a findWinner function?

It was a parameter. After looking more carefully at it, I moved all my if/ else statements with userChoice and computerChoice within the determineWinner function and it worked.

1 Like