I'm working with a JSON object retrieved from an API
let arr = [{"name": 'abc',"age": '23'},{"name": 'qwe',"age": '37'},{"name": 'wqewqe',"age": '27'}]
Now I need to create a function that can be called
public testFunc(data, prop){
console.log('Desired property value : ', data[1][prop])
}
If I call
this.testFunc(arr,'name');
The expected output would be
Desired property value : qwe
Could anyone provide me with guidance on how to achieve this?
Thanks in advance