From 2b8b98ac7f564fd421becd2c47fdd5c940d6de8c Mon Sep 17 00:00:00 2001 From: Siarhei Date: Wed, 8 Aug 2018 14:23:35 +0400 Subject: [PATCH] Simplify average --- snippets/average.md | 2 +- test/average/average.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/average.md b/snippets/average.md index 5f2851a96..d358542f2 100644 --- a/snippets/average.md +++ b/snippets/average.md @@ -5,7 +5,7 @@ Returns the average of two or more numbers. Use `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array. ```js -const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length; +const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; ``` ```js diff --git a/test/average/average.js b/test/average/average.js index dfbc90d3c..b1ddb1022 100644 --- a/test/average/average.js +++ b/test/average/average.js @@ -1,2 +1,2 @@ -const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length; +const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; module.exports = average;