Last active
August 29, 2015 14:22
-
-
Save marr/c40079597f1f7650b904 to your computer and use it in GitHub Desktop.
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
// true if any objects values are truthy | |
function any(object) { | |
return Object.keys(object).some(k => !!object[k]); | |
} | |
// filter empty values from object and return filtered object | |
function filterObject(object) { | |
if (object) { | |
const filteredObject = {}; | |
Object.keys(object).forEach(k => { | |
if (any(object[k])) { | |
filteredObject[k] = object[k]; | |
}; | |
}); | |
return filteredObject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment