Added 2 tests, fixed first numbers and passed them in exercise 10
This commit is contained in:
parent
ad1ef473d6
commit
7c157bdc29
|
@ -1,6 +1,7 @@
|
||||||
const fibonacci = function(number, b) {
|
const fibonacci = function(number) {
|
||||||
let sum;
|
let a = 1, b = 1;
|
||||||
for (let i = 0, a = 1, b = 1;
|
let sum = a;
|
||||||
|
for (let i = 0;
|
||||||
i < number - 2;
|
i < number - 2;
|
||||||
i++, (i % 2 == 0) ? a = sum : b = sum) {
|
i++, (i % 2 == 0) ? a = sum : b = sum) {
|
||||||
sum = a + b;
|
sum = a + b;
|
||||||
|
|
|
@ -16,6 +16,12 @@ describe('fibonacci', () => {
|
||||||
test('25th fibonacci number is 75025', () => {
|
test('25th fibonacci number is 75025', () => {
|
||||||
expect(fibonacci(25)).toBe(75025);
|
expect(fibonacci(25)).toBe(75025);
|
||||||
});
|
});
|
||||||
|
test('1st fibonacci number is 1', () => {
|
||||||
|
expect(fibonacci(1)).toBe(1);
|
||||||
|
});
|
||||||
|
test('2nd fibonacci number is 1', () => {
|
||||||
|
expect(fibonacci(2)).toBe(1);
|
||||||
|
});
|
||||||
test.skip('0th fibonacci number is 0', () => {
|
test.skip('0th fibonacci number is 0', () => {
|
||||||
expect(fibonacci(0)).toBe(0);
|
expect(fibonacci(0)).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue