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
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