Created
August 7, 2016 14:17
-
-
Save tonykambo/d50ec72513dd6d367aa493bd8c2bf6ff to your computer and use it in GitHub Desktop.
Ignores null values in array
This file contains hidden or 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
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