Skip to content

Instantly share code, notes, and snippets.

@mason-stewart
Last active December 24, 2015 15:19
Show Gist options
  • Select an option

  • Save mason-stewart/6819173 to your computer and use it in GitHub Desktop.

Select an option

Save mason-stewart/6819173 to your computer and use it in GitHub Desktop.
function sumNestedArrays (i){
var total = 0;
return (function sum (list) {
list.forEach(function(x){
if (Array.isArray(x)) { sum(x) }
if (typeof(x) == 'number'){ total += x; }
})
return total
})(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment