Skip to content

Commit 55ff0ad

Browse files
HRIDYANSHU054Hridyanshu7appgurueu
authored
docs: fixed misleading comment about the array method (forEach instead of reduce) used in AverageMean.js (#1727)
* docs: fixed misleading comment about the array method (forEach instead of reduce) used in AverageMean.js * fix: optimized AverageMean.js by removing redundant comments and unnecessary operations. * Update Maths/AverageMean.js Co-authored-by: Lars Müller <[email protected]> --------- Co-authored-by: Hridyanshu7 <[email protected]> Co-authored-by: Lars Müller <[email protected]>
1 parent ff314a2 commit 55ff0ad

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Diff for: Maths/AverageMean.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ const mean = (nums) => {
1313
throw new TypeError('Invalid Input')
1414
}
1515

16-
// This loop sums all values in the 'nums' array using forEach loop
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
16+
return nums.reduce((sum, cur) => sum + cur, 0) / nums.length
2117
}
2218

2319
export { mean }

0 commit comments

Comments
 (0)