My text file contains one small array (for simplicity here) of two objects as shown in array1. I want to load this text file and manipulate the array in further downstream steps. When it loads, it says it is a string, and as such prohibits array manipulation. How can load and manipulate my array after it loads?
var request = require('request');
var cheerio = require('cheerio'),
var fs = require('fs');
array1 = fs.readFileSync('smallArray.txt', 'utf8');
console.log(typeof array1);
//logs string!!
var array2 = [{"username":"one","name":"158","EF":40.745954}, {"username":"two","name":"216","EF":24.016202};
console.log(typeof array2);
// logs object!!