Answers for "nodejs array write to lines file"

0

nodejs array write to lines file

let arr = ["a", "b", "c", "d", "e", "f"];

console.log(arr); // [ 'a', 'b', 'c', 'd', 'e', 'f' ]

console.log(arr.join('\n'));
// a
// b
// c
// d
// e
// f

let text = arr.join('\n');

fs.writeFileSync('modified.txt', text, "utf8");
Posted by: Guest on July-08-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language