I wanted to solve the problem in node js:
Write a program for adding two integers. At the input, two natural numbers A and B less than 200 are given on separate lines. The output should contain the value of their sum, A + B. (https://pl.spoj.com/problems/PTEST/)
My first attempt:
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("A ? ", function(A) {
rl.question("B ?\n", function(B) {
console.log(parseInt(A) + parseInt(B));
rl.close();
});
});
The second attempt:
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('', A, B => {
console.log(parseInt(A)+parseInt(B));
readline.close();
});
but both don't work (https://pl.spoj.com/submit/PTEST/)