Rock Paper Scissors Project JS

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

Why in the hint of when you’re stuck in the userinput the or operator used instead of just using the comma for the multiple strings? Also I am super confused as to why I am now closing the code block with a semicolon when before I would leave it alone?

That is not a valid expression given that it uses the assignment operator to make a comparison. It should also be noted that comparisons only take one operand so there must be three comparisons made.

if (a === 'rock' || a === 'paper' || a === 'scissors')
1 Like

I really appreciate you replying to my post. Thank you for taking your time. I am still a little confused. As i am still learning the language and not sure on what some words you just said meant. Could you break it down or use different words that i can better understand please?

a = 42    =>  assignment. `a` refers to the value `42`

a === 42  =>  comparison. `a` and `42` are the operands

Assignment is a statement; comparison is an expression.

||        =>  the OR logical operator

ok. I think I understand. So are you saying that the way I have the code is incorrect because I dont have the assigned operator listed multiple times along with the values for them?

If you look at the earlier example you can see there are three independent expressions, all comparisons. They must be written with the comparison operator for identity, ===, which looks for exact match between the two operands. The net yield is a true or false value, a boolean.