Skip to content

Commit 1c07c61

Browse files
committed
Fix findMax function to correctly filter non-numeric values and update test case for consistency
1 parent 4e5a380 commit 1c07c61

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎Sprint-1/implement/max.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
function findMax(elements) {
2+
const numbers = elements.filter((item) => typeof item === "number");
3+
return Math.max(...numbers);
24
}
35

46
module.exports = findMax;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test("given an empty array, returns -Infinity", () => {
2525
// Then it should return that number
2626

2727
test("given an array with one number, returns the number", () => {
28-
expected(findMax([12])).toBe(12);
28+
expect(findMax([12])).toBe(12);
2929
});
3030

3131
// Given an array with both positive and negative numbers

0 commit comments

Comments
 (0)