Created
October 6, 2020 14:59
-
-
Save amnuts/47c2d874aebb37cdb49e5b7897840414 to your computer and use it in GitHub Desktop.
Helpers to see if object has all props or any of the props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hasAllProps = function(list, within) { | |
list.forEach(function(e) { | |
if (!within.hasOwnProperty(e) || within[e] == "") { | |
return false; | |
} | |
}); | |
return true; | |
}; | |
const hasAnyProps = function(list, within) { | |
let found = false; | |
list.forEach(function(e) { | |
if (within.hasOwnProperty(e) && within[e]) { | |
found = true; | |
} | |
}); | |
return found; | |
}; | |
module.exports = { | |
hasAllProps, | |
hasAnyProps | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment