[Home] > Snippets  > Languages  > JavaScript  > Numbers  >  Calculate the remainder of division of arguments

Calculate the remainder of division of arguments

JavaScript

const remainder = (...args) => args.reduce((a, b) => a % b)

TypeScript

const remainder = (...args: number[]): number => args.reduce((a, b) => a % b)

Examples

remainder(1, 2, 3, 4) // 1