Last active
August 14, 2019 12:41
-
-
Save gatarelib/80860289737ad9af6e097f84fd2e9fe0 to your computer and use it in GitHub Desktop.
Andela assessment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let power = (a,b) => { | |
if (b <= 1) { | |
return a; | |
} else { | |
return a * power(a, b-1); | |
} | |
}; | |
power(3, 4); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = require("chai").assert; | |
describe("Recursion", () => { | |
describe("power(2, 3)", () => { | |
let result = power(2, 3); | |
it("Should return 8", () => { | |
assert.equal(result, 8); | |
}); | |
}); | |
describe("power(3, 3)", () => { | |
let result = power(3, 3); | |
it("Should return 27", () => { | |
assert.equal(result, 27); | |
}); | |
}); | |
describe("power(4, 4)", () => { | |
let result = power(4, 4); | |
it("Should return 256", () => { | |
assert.equal(result, 256); | |
}); | |
}); | |
describe("power(5, 5)", () => { | |
let result = power(5, 5); | |
it("Should return 3125", () => { | |
assert.equal(result, 3125); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment