From ade77f58ff11f9133e9018fc4ba8fda131f07573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=8C?= <1206180097@qq.com> Date: Fri, 22 Dec 2017 13:47:32 +0800 Subject: [PATCH] Update fibonacci.md --- snippets/fibonacci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/fibonacci.md b/snippets/fibonacci.md index 1c15dc352..e5e2e15fd 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.from({ length: n}).map(v => 0).reduce((acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), []); + Array.from({ length: n}).reduce((acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), []); // fibonacci(5) -> [0,1,1,2,3] ```