Skip to content

Latest commit

 

History

History
29 lines (18 loc) · 503 Bytes

mean.md

File metadata and controls

29 lines (18 loc) · 503 Bytes

mean

Calculates the average of an array of numbers.

If the array is empty, this function returns NaN.

Signature

function mean(nums: number[]): number;

Parameters

  • nums (number[]): An array of numbers to calculate the average.

Returns

(number): The average of all the numbers in the array.

Examples

import { mean } from 'js-utils-es/math';

const numbers = [1, 2, 3, 4, 5];
const result = mean(numbers);
// result will be 3