JSFiddle - React, Tailwind, and code Playground

by Filipe Augusto Lima de Souza

JavaScript

function choiceIf(userChoice) {
 if  (userChoice !== "rock" && userChoice  !== "scissors" && userChoice  !== "paper") {
    console.log(userChoice + " That is not one of the options");
    return false;
 }   
}

function choice(userChoice) {
    switch(userChoice)
    {
      case 'rock': break;
      case 'scissors': break;
      case 'paper': break;
      default: {
         console.log(userChoice + " That is not one of the options");
         return false;
      }
     }
}

choiceIf('rock');
choice('rock');
choiceIf('scissors');
choice('scissors');
choiceIf('paper');
choice('paper');
choiceIf('wrong');
choice('wrong');