Rock, paper, scissors project issues

I have been trying to learn Java Script and the lessons I have been going through seem to be fine but i have not started to come across the two projects of rock,paper scissors and sleep debt project and even when i have check the code and followed it up with putting in the exact code from the youtube video it still shows errors and will not let me complete it.

Please let me know if this is an ongoing issue for anyone else?

I have been at this forums for years, at this stage in the learning process, 9 out of 10 times learners made some small mistake. Which can happen, and is totally fine

the best way we can help you is if you provide:

  • your code
  • the exercise/project url
  • any possible error messages

Then we can help you solve the issue, or if there is a problem with the exercise, we would better be able to report the issue to codecademy and get it fixed

1 Like

Ok thank you for your help.
the code i have put in which i have checked many times is:

const getUserChoice = userInput => {

userInput = userInput.toLowerCase();

}

if (userInput === ‘rock’ || userInput === ‘paper’) (userInput === ‘Scissors’) {

return userInput;

} else {

console.log(‘Error!’);

}

console.log(getUserChoice(‘paper’));

console.log(getUserChoice(‘Potato’));

URL:

https://www.codecademy.com/paths/create-a-back-end-app-with-javascript/tracks/bapi-javascript-conditionals-and-functions/modules/learn-javascript-functions/projects/rock-paper-scissors-javascript

Error Message:

/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:4
if (userInput === ‘rock’ || userInput === ‘paper’) (userInput === ‘Scissors’) {
^
SyntaxError: Unexpected token {
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
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)

Thank you for your help on this

I’m not 100% sure but from my understand the error here is due to closing the constant getUserChoice too early and for that reason the program reads the rest of your input as new code instead of part of the constant.

const getUserChoice = userInput => {

userInput = userInput.toLowerCase();



if (userInput === ‘rock’ || userInput === ‘paper’) (userInput === ‘Scissors’) {

return userInput;

} else {

console.log(‘Error!’);

  }
}

console.log(getUserChoice(‘paper’));

console.log(getUserChoice(‘Potato’));

Moving the closing parenthese to after the else statement should fix it the issue from my knowledge however I stand to be corrected.

1 Like

You were right in pointing out the curly bracket.

However, did you try this piece of code? Are you sure that it works as intended? :wink:

3 Likes

I have changed this from the parenthesis to || (or) in between paper and scissors and this now works thank you very much for your help.

Thank you for pointing out my issue on this one.

1 Like