Hi can someone explain to me why this code does not return my error message?
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || ‘paper’|| ‘scissors’)return userInput
else console.log (‘Error, option unavailable’)
};
console.log(getUserChoice(‘book’));
// I’ve looked at the hint and I am aware that it should be written userInput === ‘rock’, userInput === ‘paper’… - but I cant quite understand how it does not view book as a wrong input.
Thank you
The if clause checks for truthiness. And your condition is truthy – always.
As you’ve correctly remarked, you should have written userInput === 'rock' || userInput === 'paper')
.
But what you’ve currently written is in plain words:
If userInput is rock or if paper or if scissors
That means that you aren’t comparing the input with the strings paper and scissors, but you only check if paper or scissors are truthy – which they are.
Thanks for the swift reply, very much appreciated 
1 Like
so it basically, just becomes a truthy statement because the three different strings can only be identified as truthy? sorry if this is a silly question
Yes. Strings evaluate to truthy, so the second and the third condition are truthy. The first condition is a comparison that is false.
Maybe this helps:
const var1 = '';
const var2 = 'any string';
console.log(!!var1); // false
console.log(!!var2); // true