0

I'm new to learning javascript and I'm trying to make a rock paper scissors game. I'm trying to run an if statement to check if the player has input a valid answer, but it's always returning true.

function validThrow(playerThrow){
  if (playerThrow === 'Rock' || 'Paper' || 'Scissors'){
      return true;
  } else{
      return false;
  }
}

No matter what playerThrow is it's always returning true. What am I missing here?

  • 1
    change `(playerThrow === 'Rock' || 'Paper' || 'Scissors')` to `(playerThrow === 'Rock' || playerThrow === 'Paper' || playerThrow === 'Scissors')` – ericmp Nov 08 '22 at 15:36
  • It's being evaluated as `((playerThrow === 'Rock') || ('Paper') || ('Scissors'))`; the strings `Paper` and `Scissors` are *truthy*. – mykaf Nov 08 '22 at 15:38

0 Answers0