* Calculates the remainder of the division of two numbers. * @param {number} a - The dividend * @param {number} b - The divisor * @returns {number} The remainder of a divided by b * @throws {Error} If b is zero
(a, b)
| 62 | * @throws {Error} If b is zero |
| 63 | */ |
| 64 | function modulo(a, b) { |
| 65 | if (b === 0) { |
| 66 | throw new Error(`Modulo by zero is undefined. Inputs were: a=${a}, b=${b}`); |
| 67 | } |
| 68 | return a % b; |
| 69 | } |
| 70 | |
| 71 | // Test cases |
| 72 | function runTests() { |