T
T
TRUEC0DER2021-02-02 12:30:40
Node.js
TRUEC0DER, 2021-02-02 12:30:40

How to make code repetition in readline?

There is code using readline:

rl.question('Lorem ipsum: ', (answer) => {
  console.log('Lorem ipsum ' + answer)
})

It is necessary that after receiving a response, the code does not end, but repeats over a new one (Ask a question, after which it again executes the code that is inside. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RokeAlvo, 2021-02-02
@RokeAlvo

I don’t know what rl is, but something like this (I’m writing from my phone)

function fn(answer){
  console.log(answer)
  rl.question(“aaaa”, fn)
}

rl.question(“aaa”, fn)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question