Calculates the average of the given array of numbers.

Type signature

(xs?: number[]) => number

Examples

average([2, 4, 15]);
// ⇒ 7
Try in REPL

Questions

  • How to compute the average of an array?

TypeScript sourceJavaScript source