Rock paper scissors else syntax error

here is my code,
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’); {
return userInput;
} else {
console.log(‘YOU DUMMY’);
}
}

I cannot for the life of me figure out why this isn’t working, and after watching the walkthrough video it looks the exact same to me. Can someone explain to me why else is causing a problem?

Hey Levi!
A syntax error is usually due to an error in writing the correct syntax for whatever you’re doing. In your case the problem is that you added a semicolon in-between stating the if condition and the opening bracket of the code block.
You posted this:

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase();
  if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’); {
    return userInput;
  } else {
    console.log(‘YOU DUMMY’);
  }
}

What it should be:

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase();
  if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’){
    return userInput;
  } else {
    console.log(‘YOU DUMMY’);
  }
}

Can you notice the difference?

Also, next time you post code in here please write three backticks ``` before and after the code block in order to style formatting it and making it more visible.

Does this solve your problem? :slight_smile:

1 Like