Last active
August 29, 2015 14:26
-
-
Save SeeThruHead/173d1c95eeb9b21b68dd 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
function isInt(x) { | |
return (typeof x === 'number') && (x % 1 === 0); | |
} | |
function flatten(ar) { | |
return ar.reduce(function(prev, curr) { | |
return prev.concat((Array.isArray(curr) ? flatten(curr) : curr)); | |
}, []); | |
} | |
function arraySum(i) { | |
return flatten(i).reduce(function(prev, curr) { | |
return isInt(curr) ? prev + curr : prev; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment