I'm trying to access a key of an object. But that isn't working. Can anyone help me out here?
So I've an object and a string that points to the value I've to access inside the object. And that value is two levels down.
const obj = { name: 'yash', { hobbies: { sports: ['football', 'tennis']} } };
// this is an example object, I have a string
const item = 'hobbies.sports';
// now I want to access the object with this item
obj[item] // but this isn't working.