Rock Paper Scissors - first step

Hello, Sorry to bother you all. I got stuck on the first step, may i know what’s wrong with my code here that my function doesn’t work? Thanks!!

I paste below as well:

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

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

1 Like

When calling the function you need the function’s name, not It’s attribute’s name:

console.log(getUserChoice('paper'));

And use return here, because when you call it like this it will throw Error! and undefined(of course, this wasn’t the thing that caused an error.)

Hope this helps :grinning:

2 Likes

Thanks so much!!!

2 Likes