From 2ba9279b8cd996b7e771a38a954c7e217364992f Mon Sep 17 00:00:00 2001 From: King Date: Thu, 21 Dec 2017 07:24:10 -0500 Subject: [PATCH 1/2] update fibonacci Array() -> Array.from() --- snippets/fibonacci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/fibonacci.md b/snippets/fibonacci.md index a669c344d..1c15dc352 100644 --- a/snippets/fibonacci.md +++ b/snippets/fibonacci.md @@ -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] ``` From 4ff3f4f5fda112d3d22f2026e2f8d5abd5e1cf95 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 21 Dec 2017 07:26:40 -0500 Subject: [PATCH 2/2] ran npm run builder --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d48327a92..2aabd659e 100644 --- a/README.md +++ b/README.md @@ -1242,7 +1242,7 @@ 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] ```