When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!
when i run my rock paper scissors program it does not work and shows this message:
/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2
userInput = userInput.toLowerCase();
^
TypeError: Cannot read property ‘toLowerCase’ of undefined
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:24)
at Object. (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:55: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)
at startup (bootstrap_node.js:151:9)
RangeError: Maximum call stack size exceeded
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:1:85)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
at getUserChoice (/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:2:3)
You need to delete the second line of the function.
A function that contains a call to itself results in an infinite loop. This is known as recursion and while it can be implemented in a program, it needs careful control so that it at some point actually ends. For another topic down the road.
Hello, @qu3sting1. Could you re-post your current code using the following instructions?
Code that is posted without the indentations, whitespace and special characters preserved, is very difficult to read, and cannot easily be tested by those trying to help you.
The Codecademy forum provides a quick and easy way to post properly-formatted code. All you need to do is look for the </> icon in the menu bar which appears at the top of the text box while you type.
Press Enter to go to a blank line, click that icon, and you will see this:
Just copy and paste your code directly from the editor into that highlighted portion, and all of the nicely-readable formatting will be preserved! Moreover, it will be in a format that can be directly copied and pasted into an IDE for testing.
The same icon can be used for highlighting small code snippets in-line for clarity.
I suggest fixing your indentation, match it to your braces. You’ll probably find some issues while doing that which you were hiding from yourself with the arbitrary indentation.
Where things begin and end is not negotiable, and indentation is how you keep track of it. You’re not supposed to be counting braces, that’s far too difficult and far too much effort.
Echo what @ionatan said. I copied and pasted your code, and got it to work. Cleaning up the indentation will help immensely. You have a couple of misplaced curly braces. Other than that your code works as expected. When you don’t follow consistent indentation, it is very difficult to locate missing or extra { }'s.