10000 add fibonacci · CalWal/javascript-exercises@bdc61b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit bdc61b6

Browse files
committed
add fibonacci
1 parent 4dc7776 commit bdc61b6

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ The first exercise, `helloWorld` will walk you through the process in more depth
1414
## planned exercises (in no particular order for the moment):
1515
1. book titles (MC)
1616
1. pig latin (MC)
17-
1. fibonacci
18-
1. convert to snake case

fibonacci/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Exercise XX - fibonacci
2+
3+
Create a function that returns a specific member of the fibonacci sequence:
4+
5+
> a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
6+
7+
```javascript
8+
fibonacci(4) // returns the 4th member of the series: 3 (1, 1, 2, 3)
9+
fibonacci(6) // returns 8
10+
```

fibonacci/fibonacci.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var fibonacci = function() {
2+
3+
}
4+
5+
module.exports = fibonacci

fibonacci/fibonacci.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var fibonacci = require('./fibonacci')
2+
3+
describe('fibonacci', function() {
4+
it('works', function() {
5+
expect(fibonacci(4)).toEqual(3);
6+
});
7+
xit('works', function() {
8+
expect(fibonacci(6)).toEqual(8);
9+
});
10+
xit('works', function() {
11+
expect(fibonacci(10)).toEqual(55);
12+
});
13+
xit('works', function() {
14+
expect(fibonacci(15)).toEqual(610);
15+
});
16+
xit('works', function() {
17+
expect(fibonacci(25)).toEqual(75025);
18+
});
19+
xit('doesn\'t accept negatives', function() {
20+
expect(fibonacci(-25)).toEqual("OOPS");
21+
});
22+
xit('DOES accept strings', function() {
23+
expect(fibonacci("8")).toEqual(21);
24+
});
25+
});

0 commit comments

Comments
 (0)
0