We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1276daa commit 252ff10Copy full SHA for 252ff10
Maths/AverageMean.js
@@ -13,11 +13,7 @@ const mean = (nums) => {
13
throw new TypeError('Invalid Input')
14
}
15
16
- // This calculates the sum of all values in the 'nums' array using reduce method.
17
- const sum = nums.reduce((sum, cur) => sum + cur, 0)
18
-
19
- // Divide sum by the length of the 'nums' array.
20
- return sum / nums.length
+ return nums.reduce((sum, cur) => sum + cur / nums.length, 0)
21
22
23
export { mean }
0 commit comments