I need to create a function that looks inside a nested object for a specific {key:value}.
The object, key, and value will be given as a parameter. If both the key and value are in the object together I have to return true, otherwise false
function objContains = function(obj, prop, value){
for (let key in obj) {
if (typeof obj[key] === 'object') {
objContains(obj[key], prop, value)
}
if (obj.hasOwnProperty(prop) && obj[key] === value) {
return true
}
}
return false
}
I tried this but I can´t make it work