The following code reads a file and turned each line into array items:
fs.readFile('en.txt', 'utf8', function (err, data) {
if (err) {
return console.log(err)
}
enStrings = data.split(/[\r\n]+/g)
}
en.txt looks like this:
Line 1
Line 2
Line 3
But I'm puzzled. console.log(enStrings) outputs this:
[ 'Line 1', 'Line 2', 'Line 3', '' ]
Why is that last empty item being added? And how to remove it?