I'm trying to split text into an array and then ultimately create a new file with the contents of that array.
However, when I do this, the text file contains a comma-delimited list instead of using array notation.
Here is the code so far:
var input = "4 Every Dog Must Have His 66 Every Day,";
var lorem = function(text) {
var textArray = input.split(' ');
for (var i = textArray.length - 1; i >= 0; i--) {
if (textArray[i].match(/(\d+)$/)) {
textArray.splice(i, 1);
}
}
return textArray;
};
output = lorem(input);
var fs = require('fs');
fs.writeFile("test", output, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});