GitHub 6219★

Calculate the average of arguments

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
Follow me on and to get more useful contents.