I am working on this problem in kattis where I need to get the second integer inputted on the first line. The integers can be 1-999. In the example input below, I need to display 80:
2 80
carrots
bunnies
Here is my code:
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on("line", (line) => {
let inputData = line;
console.log(inputData)
});
In the console log inputData, it displays the whole input. I also tried to split the line using let inputData = line.split(' '); and the results werebut still I don't know how to be able to get 80 :
[ '2', '80' ]
[ 'carrots' ]
[ 'bunnies' ]