두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
첫째 줄에 A, 둘째 줄에 B가 주어진다. (0 < A, B < 10)
첫째 줄에 A+B를 출력한다.
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
rl.on("line", (line) => {
input.push(parseInt(line));
});
rl.on("close", () => {
console.log(input[0] + input[1]);
});
1000번에서 한 줄에 모두 입력을 받았던 것과 달리 여러 줄에 걸쳐 입력을 받는 형식이었기 때문에 input 배열을 만들어 입력을 받는 것으로 구현했다.