I want a function that takes the name of the row in the JSON file and returns a list of elements from that row based on that argument... if "DRIVER" is called then I should get all the drivers in that row, if "COMPANY" is called, then all the companies...I've done several attempts to get it, like concatinating +".argument" but it does not seem to work. Any help will be greatly appreciated..
const data = require('./drivers.json'); // THIS IS MY FILE
function getInfo(argument){
console.log(argument);
for (let i = 0; i < data.length; i+=1) {
console.log(data1[i].argument); //UNDEFINED
}
}
getInfo('DRIVER');