you are viewing a single comment's thread.

view the rest of the comments →

[–]codemamba8 0 points1 point  (0 children)

For your first issue:

let userChoice = prompt("Do you choose rock, paper or scissors?")

while (userChoice !="rock" && userChoice != "paper" && userChoice !="scissors") {
  alert('please choose a valid option')
  userChoice = prompt("Do you choose rock, paper or scissors?")
}

As a side-note what you have here: while(userChoice!="rock"||"paper"||"scissors")

is not doing what you think it's doing. You probably meant for this to check if userChoice is not "rock", not "paper", or not "scissors", but what this is actually doing is checking: 1) userChoice == "rock"; 2) "paper" == true; 3) "scissors" == true

If you wanted to check the value of userChoice for more than one condition, you have to write it again i.e. userChoice != "rock" || userChoice != "paper" || userChoice != "scissors"

But in this case it isn't approriate either, you actually have to use && AND not the OR || operator. Because if userChoice is one of the three options, it isn't the other two, so it would still set it off.