toLowerCase(); gives me an ERROR


#1

userInput=userInput.toLowerCase();

Gives me an error message as such:

/home/ccuser/workspace/javascript_101_Unit_3/rockPaperScissors.js:9
userInput=userInput.toLowerCase();
^

ReferenceError: userInput is not defined
at Object.

Appreciate if someone can help. Thank you


#2

This error is telling you the variable userInput is not defined in your code (or at least not in the scope).

userInput = userInput.toLowerCase(); //-> ReferenceError as `userInput` is not defined yet

For example:

var foo = 'Hello there'; //-> the variable is declared and initialized to a string
foo = foo.toLowerCase() //-> 'hello there'

Check your code for where you are declaring userInput before you try to use .toLowerCase().


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.