I have a conditional array ARR and I want to write values to it in one row
I try to do this
import * as readline from 'node:readline/promises'; import { stdin as input, stdout as output } from 'process'; const rl = readline.createInterface({input, output}) let arr =[] console.log('Enter Values: ') for (let i = 0; i < 5; i++) { arr[i] = await rl.question('')
But when I do this, I get line-by-line input:
Enter Values: 1 A 2 B
I need to:
Enter Values: 1 A 2 B
readline
Separate the input stream with newlines, but you want to separate it with spaces. The following transformation flow achieves this. Note that this is used withfor wait (...) {}
instead offor (...) { wait }
.