Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
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!");
    }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Just change const userInput = console.log("Do you choose rock, paper or scissors?"); to const userInput = prompt("Do you choose rock, paper or scissors?");

about 4 years ago · Juan Pablo Isaza Report

0

If I understand you well you want to create the RPS to be playable in the console. For doing so, you need to declare the input and give it a value. For example:

const userInput = console.log("Do you choose rock, paper or scissors?");
let input = "paper"
    if(input ==="paper" || input ==="rock" || input ==="scissors"){
        console.log("Your choice is " + `${input}`);
    } else {
        console.log("Error! Try again!");
    }

Another way if you want to do it interactive is to use prompt.

const userInput = console.log("Do you choose rock, paper or scissors?");
    let input = prompt("Do you choose rock, paper or scissors?");
        if(input ==="paper" || input ==="rock" || input ==="scissors"){
            console.log("Your choice is " + `${input}`);
        } else {
            console.log("Error! Try again!");
        }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!