Lodash - mean method



Syntax

_.mean(array)

Computes the mean of the values in array.

Arguments

  • array (Array) − The array to iterate over.

Output

  • (number) − Returns the mean.

Example

var _ = require('lodash');
var values = [1, 2, 3, 4, 5];
var result = _.mean(values);

console.log(result);

Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

Output

3
lodash_math.htm
Advertisements