Trying to grab certain information from a larger array to a newer array. Is there a more efficient way I can parse out the data I want using only the indices from the desire_contents
airport_data_parser() does work but I am seeking a that can have the same output but using desire_contents
airport_data = [["JFK","New York","United States",1,true],
["BOS","Massachusetts","United States",2,false],
["LOS","Califonia","United States",3,true],
["SJC","San Juan","United States",4,false]];
currated_airport_data = [];
//desire_contents is an array that contains the values of desired indices I want
desire_contents = [0,1,3];
unwanted_contents = [2,3];//tried [2,4] but for some reason [2,3] works
var airport_data_parser = function () {
if(airport_data.length > 0) {
for(var data in airport_data) {
currated_airport_data.push(airport_data[data]);
for(contents in unwanted_contents) {
currated_airport_data[data].splice(unwanted_contents[contents], 1);
}
}
}
console.log(currated_airport_data);
}
airport_data_parser();
Desired Result
currated_airport_data = [["JFK","New York",1],
["BOS","Massachusetts",2],
["LOS","Califonia",3],
["SJC","San Juan",4]];