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

346
Views
Problema rápido en el editor VS o en el editor de node js

Cuando quiero tomar la entrada del usuario en mi código tomando el símbolo del sistema frente al código o el editor de node js dice que no está definido. Pero hasta donde sé, podemos tomar la entrada del usuario en JS por "prompt".

ejemplo :-

 function leapYear(year) { if ((year %2 == 0) && (year %100 != 0) || (year %400 == 0)) { console.log(year + " LeapYear"); } else{ console.log(year +" Not a LeapYear"); } } const year = prompt('Enter a year:'); leapYear(year);

Error de referencia no capturado: el aviso no está definido

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

0

Sí, puede obtener la entrada del usuario desde la línea de comando (entonces usando el nodo), use readline:

 const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); let input = ""; rl.question("input here:\n", function (string) { input = string; console.log("input that was entered: " + input); rl.close();

});

Es un poco más complicado que en otros idiomas.

Más aquí: https://www.educative.io/edpresso/how-to-get-user-input-from-command-line-with-javascript

Hay mucho más para leer, así que aquí está la documentación oficial:

https://nodejs.org/api/readline.html

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!