Okay, so I started doing the project and I keep getting this error, heres the code:
const getUserChoice = (userInput) => {
if(getUserChoice === ‘rock’ || ‘paper’ || ‘scissors’){
return userInput();
} else {
consol.log(‘Sorry, you can try to cheat but I wont let you!’)
}
};
userInput = userInput.toLowerCase();
getUserChoice(‘rock’);
I thought it was the location of the userInput.toLowerCase(); so I moved it here
to no avail, it keeps giving me a “userInput is undefined” error message. I tried separating it into a function instead of the way they asked and I still got errors. If anyone knows what I am doing wrong and can help me I would appreciate it.
Alright I thought it was fixed but I am still having problems. Here is the code, now it says userInput is undefined, userInput = userInput.toLowerCase(); and return userInput are wrong as well. I have been messing with this for nearly 45 minutes and I can’t get this one block of code to work, please help
const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase();
if(userInput == ‘rock’ || userInput == ‘paper’ || userInput == ‘scissors’){
return userInput();
} else {
consol.log(‘Sorry, you can try to cheat but I wont let you!’)
}
};
When I did that the other two errors would show up…
Thanks for being as patient as you have been I’ll fix the current problem and see if I can find out what is wrong with the others lol
Another problem showed up when I changed it… I feel like maybe scrapping and restarting would be a good idea lmao.
It now says
/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:3
if(userInput == ‘rock’ || userInput == ‘paper’ || userInput == ‘scissors’){
^
ReferenceError: userInput is not defined
at Object.
Okay, I think I get it. It seems I tried to do too much at once and caused a lot of problems in my code. Next time I will slow down and take it step by step. Thank you for the help! I really appreciate it!
If I have any problems down the line I will let you know