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

98
Views
How to create user input in the JavaScript console?

I'm creating a short game in the JavaScript console, and for inspiration, I looked at google's easter egg version (if you search text adventure then press f12 you can see it). I wanted input, the only way I could figure out how to have input was by having functions:

console.log('Do you like chocolate ice cream?');

function yes() {
    console.log('I don't like chocolate ice cream.');
}

function no() {
    console.log('Yeah, I agree. Who even likes chocolate ice cream anyways?');
}

But in google's version, you can just type yes, and it returns a bunch of text, no parentheses. I tried with variables but it didn't really look nice and it turned out green. Does anybody know how to make it google's way?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't really do that. The closest you can get is

var input = prompt("What is your name?");
console.log("Hello, " + input + "!");
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!