N
N
NikaMurs2022-03-16 03:17:51
Node.js
NikaMurs, 2022-03-16 03:17:51

How to read stdin in js?

There is a task: On the standard input stream, two integers are given, not less than -32000 and not greater than 32000. Print the sum of these numbers on the standard output stream.
How should data be read?
Well, do I understand correctly that the standard output is console.log?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
n1ksON, 2022-03-16
@n1ksON

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
rl.on('line', (input) => {
  console.log(input)
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question