Skip to content
24 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Add math helpers, tests and checks1// Small helpers for numbers.
Merge #3: Add multiply to math.js2/** Returns the sum of a and b. */
Add math helpers, tests and checks3function add(a, b) {
4 return a + b;
5}
6
Merge #3: Add multiply to math.js7/** Returns the product of a and b. */
8function multiply(a, b) {
9 return a * b;
10}
11
Add power function to math.js12/** Returns base raised to the whole-number exponent; throws a RangeError if exponent is negative. */
13function power(base, exponent) {
14 if (exponent < 0) {
15 throw new RangeError("exponent must not be negative");
16 }
17 let result = 1;
18 for (let i = 0; i < exponent; i++) {
19 result *= base;
20 }
21 return result;
22}
23
24module.exports = { add, multiply, power };

This file's history is long; its oldest lines are credited to the oldest commit read.