Skip to content

Commit 71b98b5

Browse files
committed
add test with 300 and new line
1 parent ad1cb78 commit 71b98b5

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎Sprint-1/implement/max.js‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
function findMax(elements) {
2-
if (elements.length < 1) {
3-
return -Infinity;
4-
} else {
5-
const filteredList = elements.filter((value) => (typeof value === "number") && (!Number.isNaN(value)))
6-
return Math.max( ...filteredList)}
7-
2+
if (elements.length < 1) {
3+
return -Infinity;
4+
} else {
5+
const filteredList = elements.filter(
6+
(value) =>
7+
typeof value === "number" &&
8+
!Number.isNaN(value)
9+
);
10+
return Math.max(...filteredList);
11+
}
812
}
913

1014
module.exports = findMax;

‎Sprint-1/implement/max.test.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ test("given an array with non-number values, returns the max and ignores non-num
6262
expect(findMax([1, "apple", 2, null, 3, undefined, 4])).toEqual(4);
6363
expect(findMax([3, "apple", 1, null, 2, undefined, 4])).toEqual(4);
6464
expect(findMax(["banana", 5, 3, "apple", 1, 4, 2])).toEqual(5);
65+
expect(findMax([1, 2, 3, "4", 5, "300", 7])).toEqual(7);
6566
});
6667

6768
// Given an array with only non-number values
@@ -71,4 +72,5 @@ test("given an array with only non-number values, returns -Infinity", () => {
7172
expect(findMax(["apple", null, undefined])).toEqual(-Infinity);
7273
expect(findMax([null, undefined])).toEqual(-Infinity);
7374
expect(findMax(["apple", "banana"])).toEqual(-Infinity);
74-
});
75+
});
76+

0 commit comments

Comments
 (0)