I have a array, its contents is, lines written like so.
John
Snow
foo
1234
Is it possible to put each line into its own variable? The max line count will be 7 lines.
I use this code to read the file into an array.
var fs = require('fs');
var array = fs.readFileSync('foo').toString().split("\n");
for(i in array) {
console.log(array[i]);
I was thinking of using the Split and Map function, but that would only result in,
John, Snow, foo ,1234 Which is not what I'm after.
My reasoning.
I am working on a little software sharing app,what I was planning, is if one of the packages needs installing, I was going to have a simple system that would allow the installation of the package like so,
unpack
install
etc
Using internal functions in the app to simplify installation, so the developers don't need to write out large install scripts, I wanted to read line by line in the file, split each line into its own variable or array, then check the value of each array, then start the correct functions.