Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 432 Bytes

calculate-the-average-of-arguments.mdx

File metadata and controls

24 lines (18 loc) · 432 Bytes
category created title updated
Number
2020-05-05
Calculate the average of arguments
2021-10-13

JavaScript version

const average = (...args) => args.reduce((a, b) => a + b) / args.length;

TypeScript version

const average = (...args: number[]): number => args.reduce((a, b) => a + b) / args.length;

Examples

average(1, 2, 3, 4); // 2.5