solutions
This commit is contained in:
parent
72878172b5
commit
d42eebaab8
|
@ -1,5 +1,13 @@
|
|||
var fibonacci = function() {
|
||||
const fibonacci = function(count) {
|
||||
if (count < 0) return "OOPS";
|
||||
let a = 0;
|
||||
let b = 1;
|
||||
for (let i = 1; i < count; i++) {
|
||||
const temp = b;
|
||||
b = a + b;
|
||||
a = temp;
|
||||
}
|
||||
return b;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
module.exports = fibonacci
|
||||
module.exports = fibonacci;
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
var fibonacci = require('./fibonacci')
|
||||
const fibonacci = require("./fibonacci");
|
||||
|
||||
describe('fibonacci', function() {
|
||||
it('works', function() {
|
||||
describe("fibonacci", () => {
|
||||
it("works", () => {
|
||||
expect(fibonacci(4)).toEqual(3);
|
||||
});
|
||||
xit('works', function() {
|
||||
it("works", () => {
|
||||
expect(fibonacci(6)).toEqual(8);
|
||||
});
|
||||
xit('works', function() {
|
||||
it("works", () => {
|
||||
expect(fibonacci(10)).toEqual(55);
|
||||
});
|
||||
xit('works', function() {
|
||||
it("works", () => {
|
||||
expect(fibonacci(15)).toEqual(610);
|
||||
});
|
||||
xit('works', function() {
|
||||
it("works", () => {
|
||||
expect(fibonacci(25)).toEqual(75025);
|
||||
});
|
||||
xit('doesn\'t accept negatives', function() {
|
||||
it("doesn't accept negatives", () => {
|
||||
expect(fibonacci(-25)).toEqual("OOPS");
|
||||
});
|
||||
xit('DOES accept strings', function() {
|
||||
it("DOES accept strings", () => {
|
||||
expect(fibonacci("8")).toEqual(21);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue