I should note that I am working with server side javascript. I have a text file on the local host in the format of:
"bla","foo"
"ble","faa"
"blu","foo"
...
I need to read that file in and compare the keys to a variable, and pull out the value if its found. Here is what I have right now:
var controlvar = 'blu';
var tbS = "C:\Users\me\list.txt";
var blaList = {};
var reader = new FileReader(tbS);
reader.onload = function(event) {
var contents = event.target.result
var lines = contents.split('\n');
var elements = lines.split(',');
blaList[elements[0]] = elements[1];
};
reader.onerror = function(event) {
console.error("File could not be read! Code " + event.target.error.code)
};
for (var key in blaList) {
if (/$controlvar/.test(key)) {
set(blaList[key], Host);
}
}