Skip to content

Commit 41b4f0d

Browse files
authored
Merge branch 'master' into master
2 parents 0e58f17 + 93e5e64 commit 41b4f0d

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* prototype methods vs methods in the constructor (Methods that inherit via the prototype chain can be changed universally for all instances)
1616
* class vs instance
1717

18-
1918
## Instructions
2019

2120
* Fork and clone this repo.

src/recursion.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Complete the following functions.
22

33
const nFibonacci = (n) => {
4-
// fibonacci sequence: 1 1 2 3 5 8 13 ... // fibonacci sequence: 1 1 2 3 5 8 13 ...
5-
// return the nth number in the sequence // return the nth number in the sequence
4+
65
if (n <= 2) return 1;
76
return nFibonacci(n - 2) + nFibonacci(n - 1);
87
};
@@ -29,7 +28,9 @@ const checkMatchingLeaves = (obj) => {
2928
leaves.push(value);
3029
}
3130
});
32-
};
31+
32+
};
33+
3334

3435
findLeaves(obj);
3536
return leaves.every(x => x === leaves[0]);

tests/recursion.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ describe('recursion', () => {
66
const fib1 = recursiveMethods.nFibonacci(5);
77
const fib2 = recursiveMethods.nFibonacci(3);
88
const fib3 = recursiveMethods.nFibonacci(1);
9-
expect(fib1).toBe(8);
10-
expect(fib2).toBe(3);
9+
expect(fib1).toBe(5);
10+
expect(fib2).toBe(2);
1111
expect(fib3).toBe(1);
1212
});
1313
});

0 commit comments

Comments
 (0)