| 1 | // Small helpers for numbers. |
| 2 | /** Returns the sum of a and b. */ |
| 3 | function add(a, b) { |
| 4 | return a + b; |
| 5 | } |
| 6 | |
| 7 | /** Returns the product of a and b. */ |
| 8 | function multiply(a, b) { |
| 9 | return a * b; |
| 10 | } |
| 11 | |
| 12 | /** Returns a divided by b; throws a RangeError when b is 0. */ |
| 13 | function divide(a, b) { |
| 14 | if (b === 0) { |
| 15 | throw new RangeError("Division by zero"); |
| 16 | } |
| 17 | return a / b; |
| 18 | } |
| 19 | |
| 20 | module.exports = { add, multiply, divide }; |