Skip to content

Instantly share code, notes, and snippets.

@lydemann
Created December 8, 2018 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lydemann/d425b3326394bb8545b20e148cd163e8 to your computer and use it in GitHub Desktop.
Save lydemann/d425b3326394bb8545b20e148cd163e8 to your computer and use it in GitHub Desktop.
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