You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Computes the average of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence.
Syntax
Average([selector])
Parameters
selector
A transform function to apply to each element. TElement selector(TSource)
Return Value
The average of the sequence of values
Remarks
If no selector function is specified the implementation assumes sequence of number values.
Example
The following code example demonstrates how to use Average to calculate an average.
varfruits=["apple","banana","mango","orange","passionfruit","grape"];varaverage=Enumerable.asEnumerable(fruits).Average(s=>s.Length);console.log("The average string length is "+average);// This code produces the following output:// The average string length is 6.5.