GitHub 6521★

Calculate the sum of arguments

JavaScript version

const sum = (...args) => args.reduce((a, b) => a + b);

TypeScript version

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

Examples

sum(1, 2, 3, 4); // 10
Follow me on and to get more useful contents.