What about else

I have had a few problems with ‘else’ statements. In conditional setups the “else” statement does not work, however, the elseifs do. Example: I am getting an error message here that there is an unexpected else token. Here the else should statement should show the console message.

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’ )
return userInput;
}
else{
console.log(“There is an error”);
};

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

Hello, @benjamin5967.

Welcome to the forum!

See my comment in your code: (scroll right)

Happy coding!

2 Likes

Thank you!
I see my curlies are out of order. That probably explains all the other times as well.

1 Like