From 1276daab1d7de4ddd9e789cd3317664d0c34758c Mon Sep 17 00:00:00 2001 From: Hridyanshu7 Date: Thu, 10 Oct 2024 18:22:14 +0530 Subject: [PATCH 1/3] docs: fixed misleading comment about the array method (forEach instead of reduce) used in AverageMean.js --- Maths/AverageMean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Maths/AverageMean.js b/Maths/AverageMean.js index 75f7b1b58e..99032297bb 100644 --- a/Maths/AverageMean.js +++ b/Maths/AverageMean.js @@ -13,7 +13,7 @@ const mean = (nums) => { throw new TypeError('Invalid Input') } - // This loop sums all values in the 'nums' array using forEach loop + // This calculates the sum of all values in the 'nums' array using reduce method. const sum = nums.reduce((sum, cur) => sum + cur, 0) // Divide sum by the length of the 'nums' array. From 252ff106b3a66f26a066cc94d2e805f397930307 Mon Sep 17 00:00:00 2001 From: Hridyanshu7 Date: Thu, 10 Oct 2024 19:26:12 +0530 Subject: [PATCH 2/3] fix: optimized AverageMean.js by removing redundant comments and unnecessary operations. --- Maths/AverageMean.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Maths/AverageMean.js b/Maths/AverageMean.js index 99032297bb..96e6e12beb 100644 --- a/Maths/AverageMean.js +++ b/Maths/AverageMean.js @@ -13,11 +13,7 @@ const mean = (nums) => { throw new TypeError('Invalid Input') } - // This calculates the sum of all values in the 'nums' array using reduce method. - const sum = nums.reduce((sum, cur) => sum + cur, 0) - - // Divide sum by the length of the 'nums' array. - return sum / nums.length + return nums.reduce((sum, cur) => sum + cur / nums.length, 0) } export { mean } From d0e1ba9b0ba07ff203fc690cfafffac9df315327 Mon Sep 17 00:00:00 2001 From: Hridyanshu <124202756+HRIDYANSHU054@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:02:39 +0530 Subject: [PATCH 3/3] Update Maths/AverageMean.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com> --- Maths/AverageMean.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Maths/AverageMean.js b/Maths/AverageMean.js index 96e6e12beb..8ae3b55992 100644 --- a/Maths/AverageMean.js +++ b/Maths/AverageMean.js @@ -13,7 +13,7 @@ const mean = (nums) => { throw new TypeError('Invalid Input') } - return nums.reduce((sum, cur) => sum + cur / nums.length, 0) + return nums.reduce((sum, cur) => sum + cur, 0) / nums.length } export { mean } 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