Instantly share code, notes, and snippets.

Embed
What would you like to do?
function containsInNestedObject(obj, val) {
// if obj === val return true
// check if val is in any of this obj's properties
// return false
}
var nestedObject = {
data: {
info: {
stuff: {
thing: {
moreStuff: {
someVal: 40,
something: 'foo2'
}
}
}
}
}
}
let hasIt = containsInNestedObject(nestedObject, 40); // true
let doesntHaveIt = containsInNestedObject(nestedObject, "foo"); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment