Skip to content

Commit e94100e

Browse files
committed
test: add validation for non-empty array in calculateMean function
1 parent c15204d commit e94100e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎Sprint-1/implement/mean.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ function calculateMean(list) {
22
if (!Array.isArray(list)) {
33
throw new Error("calculateMean requires an array of numbers");
44
}
5+
if (list.length === 0) {
6+
throw new Error("calculateMean requires a non-empty array");
7+
}
58
}
69

710
module.exports = calculateMean;

0 commit comments

Comments
 (0)