Skip to content

Instantly share code, notes, and snippets.

@tarzak
Last active October 1, 2015 12:50
Show Gist options
  • Save tarzak/aa843724b8127c197883 to your computer and use it in GitHub Desktop.
Save tarzak/aa843724b8127c197883 to your computer and use it in GitHub Desktop.
[{a:1},{a:undefined},{a:3}].reduce( function(a,b) {
if (b.a) {
return a+=b.a
}
else {
return a
}
},0)
[{a:1},{a:undefined},{a:3},{a:1},{a:undefined},{a:3},{a:1},{a:undefined},{a:3},{a:1},{a:undefined},{a:3}].reduce( function(a,b) {
if (b.a) {
return a+=b.a
}
else {
return a
}
},0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment