Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda