Skip to content

Instantly share code, notes, and snippets.

@tonykambo
Created August 7, 2016 14:17
Show Gist options
  • Save tonykambo/d50ec72513dd6d367aa493bd8c2bf6ff to your computer and use it in GitHub Desktop.
Save tonykambo/d50ec72513dd6d367aa493bd8c2bf6ff to your computer and use it in GitHub Desktop.
Ignores null values in array
var test=[50,30,null];
var sum = test.reduce(add,0);
function add(total, num) {
return total+num;
}
console.log(sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment