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