JSFiddle - React, Tailwind, and code Playground

by Jaecheol Kim

JavaScript

var funcAskUserChoice=function(){
    var userChoice = prompt("Do you choose rock, paper or scissors?");
    
    // click prompt cancel
    if(userChoice === null){
        return;
    }
    
    // input is correct
    if(userChoice === "rock" || userChoice === "paper" || userChoice === "scissors"){
        return;
    }
    
    // click confirm cancel
    if(confirm("Error. You should input rock, paper or scissors!") === false){
        return;
    }
    
    // ask again
    funcAskUserChoice();
}

// start loop
funcAskUserChoice();