From 13202cbdd786686c7561a1a3e94efe7b5569bac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E6=B5=AA=E6=B5=AA?= <675483520@qq.com> Date: Mon, 13 Aug 2018 09:36:54 +0800 Subject: [PATCH] Update initializeArrayWithRange sinppets Array.from(arrayLike[, mapFn[, thisArg]]) instand of `Array.map()` to fill with the desired values in a range --- snippets/initializeArrayWithRange.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/initializeArrayWithRange.md b/snippets/initializeArrayWithRange.md index f5f9f435a9..269a6a26f 100644 --- a/snippets/initializeArrayWithRange.md +++ b/snippets/initializeArrayWithRange.md @@ -8,7 +8,7 @@ You can omit `step` to use a default value of `1`. ```js const initializeArrayWithRange = (end, start = 0, step = 1) => - Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start); + Array.from({length: Math.ceil((end - start + 1) / step)}, (v, i) => i * step + start); ``` ```js