Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
How can I get the value from a string and write it in an output text file more than one time with it making new lines every time?

How can I get the value from a string and write it in an output text file more than one time with it making new lines every time? So I am trying to make a demo for how to save like user input in HTML to a text file using javascript, but I am not trying to do it at the moment, I am trying to do the same thing but from the console user input using readline-sync, the problem isn't in the module or anything else, the problem is when I for example type 'test' in the console it saves 'test' to a text file, but when I do the same process with another word, let's say 'hello' it removes 'test' and writes 'hello', I tried using the \n function but it didn't help, the code is down below:

const fs = require('fs')
const readline = require('readline-sync');
var userinput = 0;
userinput = readline.question(`test\n`);
fs.writeFile('Output.txt', userinput + "\n", (err) => {
      
    if (err) throw err;
})
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda