I am very new to javascript, and I want to read lines of strings into let's say an array, I used this:
const fs = require('fs');
let words = [];
fs.readFile('C:\\Users\\lenovo\\Desktop\\words.txt', 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
words.push(data);
console.log(words);
});
and it works, BUT, the output is formatted like this:
'wrong\r\n' +
'year\r\n' +
'yellow\r\n' +
'yes\r\n' +
'yesterday\r\n' +
'you\r\n' +
'young\r\n' +
'Bernhard\r\n' +
'Breytenbach\r\n' +
is there a way to fix this?