js read text file into array code example
Example 1: javascript convert file to array
var fs = require('fs');
var text = fs.readFileSync("./mytext.txt", 'utf-8');
var textByLine = text.split('\n')
Example 2: javascript store text file into string
var fs = require("fs");
fs.readFile("./mytext.txt", function(text){
var textByLine = text.split("\n")
});
Example 3: javascript add line from file to array
var fs = require('fs');
var myArray = fs.readFileSync('test.txt', 'utf8').split('\n');