Skip to content

Commit 206b600

Browse files
committed
added power function
1 parent db98644 commit 206b600

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

sketch.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ function anomalyCode(x) {
2929
return '5' + x - x;
3030
}
3131

32+
function anomalyCode(x) {
33+
return '5' + x - x;
34+
}
35+
36+
function power(base, exponent) {
37+
return Math.pow(base, exponent);
38+
}
39+
3240
module.exports = {
3341
sum: sum,
3442
sub: sub,
@@ -37,5 +45,6 @@ module.exports = {
3745
digital_root: digital_root,
3846
sayHelloTo: sayHelloTo,
3947
answer: answer,
40-
anomalyCode: anomalyCode
48+
anomalyCode: anomalyCode,
49+
power: power
4150
}

sketch.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode } = require('./sketch');
1+
const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode, power } = require('./sketch');
22

33
// test('adds 1 + 2 to equal 3', () => {
44
// expect(sum(1, 2)).toBe(3);
@@ -93,3 +93,7 @@ test('anomalyCode hundred should be 5000', () => {
9393
test('anomalyCode thousand should be 50000', () => {
9494
expect(anomalyCode(7891)).toBe(50000);
9595
})
96+
97+
test('power of one number', () => {
98+
expect(power(2, 2)).toBe(4);
99+
});

0 commit comments

Comments
 (0)