UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

11 lines (10 loc) 308 B
/** * Calculates the mean (average) of a list of numbers. * @param {...number[]} numbers - The numbers to calculate of. * @returns The mean of numbers * @example * mean(1, 2, 3, 4, 5); // 3 */ export function mean(...numbers) { return numbers.reduce((acc, num) => acc + num, 0) / numbers.length; }