Skip to content

Commit

Merge #5: Add subtract to math.js

g1tbotcommitted Parents97f2a542db72b7Browse files
2 files+7−10/2 viewed
+6−1
99 return a * b;
1010 }
1111
12+/** Returns a minus b. */
13+function subtract(a, b) {
14+ return a - b;
15+}
16+
1217 /** Returns base raised to the whole-number exponent; throws a RangeError if exponent is negative. */
1318 function power(base, exponent) {
1419 if (exponent < 0) {
4651 return Math.sqrt(variance);
4752 }
4853
49−module.exports = { add, multiply, power, mean, median, standard_deviation };
54+module.exports = { add, multiply, subtract, power, mean, median, standard_deviation };
+1−0
11 const assert = require("node:assert");
22 const math = require("./math");
3+assert.strictEqual(math.subtract(5, 3), 2);
34
45 assert.strictEqual(math.add(2, 3), 5);
56 assert.strictEqual(math.multiply(4, 5), 20);