im reading a txt file from reader object onload and it reads fine but i want to save specific results in an array to later traverse on but it doesn't work with array index given like arr[0], here is my code;
function loadData(item) {
    let finalString = new Array();
    let reader = new FileReader();
    var header_read = false, status_index = 0;
    reader.onload = function (progressEvent) {
        var lines = this.result.split("\n");
        for (var line = 0; line < lines.length - 1; line++) {
            var tmpArray = lines[line].split("\t");
            if(line === 0){
                const isStatus = (element) => element.toLowerCase() === 'status';
                var cur_index = tmpArray.findIndex(isStatus); 
            }else{
                finalString.push(tmpArray[cur_index]);
            }
        }
    };
    reader.readAsText(item);
    for(let try1 in finalString){
        console.log(finalString[try1]);
    }
}  
I've tried many things all around the internet but nothing seems so work for me
 
    