Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6 from nielsenteixeira/master

Method Sum
  • Loading branch information...
commit 5d4c1499b88608c213355ffcb418b7c9a359d9ec 2 parents 926c7a2 + d08b31d
@Marak authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/JSLINQ.js
View
11 lib/JSLINQ.js
@@ -172,6 +172,17 @@
},
LastOrDefault: function(defaultValue) {
return this.Last() || defaultValue;
+ },
+ Sum: function(clause){
+ var sum = 0;
+
+ for (var i = 0; i < this.items.length; i++) {
+ if (clause(this.items[i])) {
+ sum += clause(this.items[i]);
+ }
+ }
+
+ return this.items = sum;
}
};
})(this.window || exports, this.window === this ? "JSLINQ" : "Exec");
Please sign in to comment.
Something went wrong with that request. Please try again.