JavaScript Rock Paper Scissors - User input won't display in console
I'm trying to make a RPS game to play in the console. This is what I have so far. At the moment it is only console logging "Do you choose rock, paper or scissors?" and "Error! Try again!"). In other words it is not checking if the user is actually entering 'rock, paper or scissors.' What am I doing wrong?
const userInput = console.log("Do you choose rock, paper or scissors?");
if(userInput ==="paper" || userInput ==="rock" || userInput ==="scissors"){
console.log("Your choice is " + `${userInput}`);
} else {
console.log("Error! Try again!");
}
Solution 1:
Just change const userInput = console.log("Do you choose rock, paper or scissors?");
to const userInput = prompt("Do you choose rock, paper or scissors?");