JavaScript Rock Paper Scissors

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!”);

Do you see anything wrong with

I can’t find anything wrong with this particular line: In case you’re looking at the odd quote marks that is due to the unformatted code…
I’ve got doubts about these lines instead:

If ‘userInput’ is a console.log rather than a string the condition won’t ever be true.
And this:

You’re mixing template literals and string concatenation syntax:
Either you use template literals wrapped in backticks:

`any string${userInput}`

or string concatenation:

'any string' + userInput

But maybe the latter is also due to the unformatted code. Please format your code according to this guide, so anyone can tell syntax errors:

apparently you’re looking for prompt rather than console.log.

1 Like