For example this code writes the entire array to a single line:
var fs = require('fs');
fs.writeFileSync('myfile.txt', mydataarray, 'utf-8');
Where as this code needs a loop and multiple call to fs API.
for(var i = 0; i < mydataarray.length; i++){
fs.appendFile('myfile.txt', mydataarray[i]+"\n", (err) => {
if (err) throw err;
});
}
Is there a way to do this at once like the first example?