Subtract arguments
JavaScript version
const subtract = (...args) => args.reduce((a, b) => a - b);
TypeScript version
const subtract = (...args: number[]): number => args.reduce((a, b) => a - b);
Examples
subtract(1, 2, 3, 4); // -8
JavaScript version
const subtract = (...args) => args.reduce((a, b) => a - b);
TypeScript version
const subtract = (...args: number[]): number => args.reduce((a, b) => a - b);
Examples
subtract(1, 2, 3, 4); // -8