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] ```