Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Method Sum #6

Merged
merged 1 commit into from May 19, 2011
Jump to file or symbol
Failed to load files and symbols.
+11 −0
Split
View
@@ -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");