GitHub 6219★

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