String for an array inside a loop - javascript / nodejs

0

I want to pass the strings of a txt file to an array and as soon as each line was passed to the array the program would run it normally, then it would repeat and pick up the second string from the txt file. Everything is being done in javascript / nodejs but it's been 2 days since I've stopped working on it and I can not get out of the corner.

loop code with the file and array:

function email_parser(){
var fs = require('fs');
var email_count = "";
var array = [];

var array = fs.readFileSync('email.txt').toString().split("rn");
for(var i = 0; i < array.length; i++) {
    email_count = array[i];
}}

and I'm calling the variable this way

email = email_parser();

Thank you!

    
asked by anonymous 10.09.2017 / 14:42

1 answer

0

You are separating the lines the wrong way, you have to use "\".

Test like this:

.split(/\n/).map(line => line.trim());
    
10.09.2017 / 15:26