Help me with Rock Paper Scissors Project! .toLowerCase isn't working?

Hi there,

I’m working on the Rock Paper Scissors project in intro to JS and I’m not sure if it’s a bug but the code is giving me an error from .toLowerCase. I watched the tutorial video and tried copy/pasting the code directly as well as writing it out myself. For some reason, it looks like the userInput.toLowerCase is in light blue but it shouldn’t be.

Any help would be amazing! I’m on my free trial still and I’d like to try out a few of the different projects to figure out if I want to continue paying but I’m getting stuck here. Thanks!

Since I’m a “new user” I can only post one image so here’s my code (I thought the code would be helpful because the colors look wrong):

The error message says:

userInput = userInput.toLowerCase();

TypeError: Cannot read property ‘toLowerCase’ of undefined
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:3:24)
at playGame (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:59:20)
at Object. (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:66:1)
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)

Can you copy and paste your whole code, please?


The error says it all ==> userInput is not defined. Are you passing any arguments to the getUserChoice function upon calling? I’m assuming you are calling it without.


// should be

getUserChoice('paper'); // or any other choice

Happy coding!


Yeah that’s my thought as well.