I want to query all of the objects in the window object, looking for any window.object that has objects nested inside of it. If one of the key values of a nested object matches a given string, I want to return the key value of the window object that contained it.
window.mysteryObj = {
obj1:{
abc: 1,
def: 2,
},
obj2:{
ghi: 3,
jkl: 4,
}
}
const keyValue = "ghi"
function findMysteryObj (key, object){
//some logic here
return objectName
}
findMysteryObj(keyValue, window); // should return "mysteryObj"
Can someone offer some guidance on how this can be done?