2

I am trying to write a multiline string out to the console, but I am having issues. I thought I could use \r to go to a new line but it doesn't seem to be working, I end up with nothing displayed in the console.

I want to loop over an array of arrays and log each one out joined by a new line. I want to use process.stdout.write with \r's rather than \n's so I can go back and redraw the whole thing. I am fairly new to node so may be missing something obvious...

Example code:

this.grid.forEach((row) => {
  process.stdout.write(`${row.join(' ')}\r`);
});

If I omit the \r then I see the last line only

Heather Roberts
  • 1,978
  • 1
  • 24
  • 33

0 Answers0