update fibonacci Array() -> Array.from()

This commit is contained in:
King
2017-12-21 07:24:10 -05:00
parent f8e1357cbb
commit 2ba9279b8c

View File

@ -7,6 +7,6 @@ Use `Array.reduce()` to add values into the array, using the sum of the last two
```js
const fibonacci = n =>
Array(n).fill(0).reduce((acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), []);
Array.from({ length: n}).map(v => 0).reduce((acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), []);
// fibonacci(5) -> [0,1,1,2,3]
```