Skip to content

Instantly share code, notes, and snippets.

@dferber90
Last active August 29, 2015 14:22
Show Gist options
  • Save dferber90/d20e864c7a9f7bd7db81 to your computer and use it in GitHub Desktop.
Save dferber90/d20e864c7a9f7bd7db81 to your computer and use it in GitHub Desktop.
Rest Operator
// ES5
UI.registerHelper('sum', function (/* arguments */) {
var summands = Array.prototype.slice.call(arguments);
summands.pop(); // remove last argument hash (Spacebars.kw)
var sum = 0;
for (var i = 0; i < summands.length; i++) {
sum += summands[i];
}
return sum;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment