9/9 Next Steps - How to reassign new choice


#1

I'm trying to find a way to reassign a new choice to userChoice if they don't choose 'rock', 'paper' or 'scissors' the first time around. Could I do something like this:

var userChoice = prompt("Do you choose rock, paper or scissors?");
if (userChoice === "rock") {
console.log("You chose rock!");
} else if (userChoice === "paper") {
console.log("You chose paper!");
} else if (userChoice === "scissors") {
console.log("You chose scissors!");
} else {
var newChoice = prompt("Not an option. Please choose 'rock', 'paper' or 'scissors'.");
newChoice = userChoice;
};

Why won't it work?


#2

If you want that code to work with the new thing you added, you have to add another code that shows an if statement again. The code goes from up to down, so you need to add/copy the same thing below your code again so it would work. A better way is to use newChoice to do the same thing in which you did with the userChoice.


#3

You do not need semicolon in your last line

var newChoice = prompt("Not an option. Please choose 'rock', 'paper' or 'scissors'.");
newChoice = userChoice;
}

You closing here an IF statement not a function