Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Created November 19, 2014 14:42
Show Gist options
  • Select an option

  • Save shaunwallace/fef813c6c992e458a261 to your computer and use it in GitHub Desktop.

Select an option

Save shaunwallace/fef813c6c992e458a261 to your computer and use it in GitHub Desktop.
Array.prototype.reduceRight()
// will return 15
[1,2,3,4,5].reduceRight(function(previousValue, currentValue){
return previousValue + currentValue;
});
// will return 25 since we passed in the initial value
[1,2,3,4,5].reduceRight(function(previousValue, currentValue){
return previousValue + currentValue;
}, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment