This project is read-only.

sum()

The sum linq operator returns either (1) the sum of the items in the collection or (2) the sum of the values projected from the collection by the "selector" function.
var arr1 = [1, 2, 3, 4, 5];

var arr2 = [{name: 'john', age: 23},
    {name: 'amy', age: 18},
    {name: 'paul', age: 46}];

// val1 = 15
var val1 = $linq(arr1).sum();

// val2 = 87
var val2 = $linq(arr2).sum("x => x.age");

average()

The average linq operator returns either (1) the average value of the items in the collection or (2) the average value of the values projected from the collection by the "selector" function.
var arr1 = [1, 2, 3, 4, 5];

var arr2 = [{name: 'john', age: 23},
    {name: 'amy', age: 18},
    {name: 'paul', age: 46}];

// val1 = 3
var val1 = $linq(arr1).average();

// val2 = 29
var val2 = $linq(arr2).average("x => x.age");

Last edited Sep 11, 2012 at 8:13 PM by battousai999, version 2