Skip to content

Commit 95d7bdd

Browse files
committed
Added check for Nan, Infinity and -Infinity in median.js
1 parent 63f79bb commit 95d7bdd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sprint-1/fix/median.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function calculateMedian(list) {
1111
return null;
1212
} else {
1313
// Get only numeric values
14-
const numericList = list.filter((item) => typeof item === "number");
14+
const numericList = list.filter((item) => Number.isFinite(item));
1515
// Check if its empty after filtering
1616
if (numericList.length === 0) {
1717
return null;

0 commit comments

Comments
 (0)