Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Maths/AverageMean.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }