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 <34514239+appgurueu@users.noreply.github.com> --------- Co-authored-by: Hridyanshu7 <himank7794@gmail.com> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
1 parent ff314a2 commit 55ff0ad

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Maths/AverageMean.js

Lines changed: 1 addition & 5 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy