I am trying to access a nested object based on the name of the object
I have already tried what I did below but it is giving me an error saying that "Cannot read property 'amount' of undefined" Can someone please explain to me why this doesn't work to point me in the direction of an alternative method? Thanks
var test = {
"name": {
"amount": "200"
},
"telle": {
"amount": "150"
}
}
function getIt(testing) {
return test.testing.amount;
//return test.name.amount;
}
console.log(getIt("name"))