mercredi 20 octobre 2021

if else problem...why the console didnt print string 'error' but it printed 'Randommm' instead?

Nice to meet you all. I am new to programming here....my question is why the console didnt print string 'error' but it printed 'Randommm' instead? since it did not pass the first statement

const getUserChoice = (userInput) => {
      userInput = userInput.toLowerCase();
      if (userInput === "rock" || "scissors" || "paper" || "bomb") {
        return userInput;
      } else {
        console.log("Error");
      }
    };
    
    console.log(getUserChoice("Randommm")); //output:'Randommm' instead of 'Error'

Aucun commentaire:

Enregistrer un commentaire