mean

math

Computes the mean of the values in array.

Signature

mean(array: number[]): number

Parameters

NameTypeDescription
arraynumber[]The array to iterate over

Returns

number - Returns the mean

Examples

Basic usage

import { mean } from 'dashlite'

const result = mean([4, 2, 8, 6])
console.log(result)

Output:

5

Empty array

import { mean } from 'dashlite'

const result = mean([])
console.log(result)

Output:

NaN

Available since version 1.0.0