From 90372b617f7d24f550ab7d1299de7ba96a2d27be Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 27 Feb 2026 23:45:24 +0000 Subject: [PATCH 01/33] feat: add a function to pass the array of number, positives and negatives and return the median --- Sprint-1/fix/median.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index b22590bc6..bb3ae77b9 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -5,10 +5,25 @@ // Hint: Please consider scenarios when 'list' doesn't have numbers (the function is expected to return null) // or 'list' has mixed values (the function is expected to sort only numbers). -function calculateMedian(list) { - const middleIndex = Math.floor(list.length / 2); - const median = list.splice(middleIndex, 1)[0]; - return median; +// [...list] create a new exactly array but independent + +function calculateMedian(list) { + // order the array to find the middle number + //we will use the spread operator to save with no order. + const sortArr = list.sort((a, b) => a - b); + console.log(sortArr); + + // divide the array to find the middle position. + const middleIndex = Math.floor(sortArr.length / 2); + + //if residual is 0, when the array is even + if (sortArr.length % 2 === 0) { + const leftHalf = sortArr[middleIndex - 1]; + const rightHalf = sortArr[middleIndex]; + return (leftHalf + rightHalf) / 2; + } + return sortArr[middleIndex]; + } module.exports = calculateMedian; From 957518352f5bc9a862ebcf5c94b485533c61e076 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 27 Feb 2026 23:51:29 +0000 Subject: [PATCH 02/33] feat: implement immutable sorting using spread operator for median calculation --- Sprint-1/fix/median.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index bb3ae77b9..d52810b02 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -9,8 +9,10 @@ function calculateMedian(list) { // order the array to find the middle number - //we will use the spread operator to save with no order. - const sortArr = list.sort((a, b) => a - b); + // const sortArr = list.sort((a, b) => a - b); + //using [...list] is a safe immutable sorting + const sortArr = [...list].sort((a, b) => a - b); + console.log(sortArr); // divide the array to find the middle position. From 7f1e727030377f51725bebbce805366c92f4dad9 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Sat, 28 Feb 2026 00:16:49 +0000 Subject: [PATCH 03/33] feat: add validation for empty or non-array input in median calculation --- Sprint-1/fix/median.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index d52810b02..9be5c1280 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,10 +6,17 @@ // or 'list' has mixed values (the function is expected to sort only numbers). // [...list] create a new exactly array but independent + // const sortArr = list.sort((a, b) => a - b); this modify the array function calculateMedian(list) { + // if the array is empty or is not array return null + if(!Array.isArray(list) || list.length === 0){ + return null; + } + + // order the array to find the middle number - // const sortArr = list.sort((a, b) => a - b); + //using [...list] is a safe immutable sorting const sortArr = [...list].sort((a, b) => a - b); From 9e447e7a170f5ee094466b9b9f81ef19c3d48f10 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Sat, 28 Feb 2026 00:42:48 +0000 Subject: [PATCH 04/33] feat: enhance median calculation by filtering non-numeric values and handling empty arrays and cleaning all data that is not number. --- Sprint-1/fix/median.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 9be5c1280..82211ce97 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -9,14 +9,23 @@ // const sortArr = list.sort((a, b) => a - b); this modify the array function calculateMedian(list) { - // if the array is empty or is not array return null - if(!Array.isArray(list) || list.length === 0){ + // if is not an array + if(!Array.isArray(list)){ return null; } + //checking only numbers and not null and empty + const numsOnly = list.filter( + (n) => typeof n === "number" && n !== null && !isNaN(n) + ); - // order the array to find the middle number + //if return numbers check if after cleaning the length is same as expected or empty + if (numsOnly.length === 0) { + return null; + } + + // order the array to find the middle number //using [...list] is a safe immutable sorting const sortArr = [...list].sort((a, b) => a - b); From bb34f14e9b04327a2dc7df068079398d8563d674 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Sat, 28 Feb 2026 00:46:52 +0000 Subject: [PATCH 05/33] feat: add data validation and non-numeric filtering to median calculation --- Sprint-1/fix/median.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 82211ce97..20e65357b 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -27,7 +27,11 @@ function calculateMedian(list) { // order the array to find the middle number //using [...list] is a safe immutable sorting - const sortArr = [...list].sort((a, b) => a - b); + // const sortArr = [...list].sort((a, b) => a - b); + + // now we change to use the numsOnly otherwise will take string as numbers + const sortArr = [...numsOnly].sort((a, b) => a - b); + console.log(sortArr); From 0db6d2ee3e8a716ce25468df7f768a44100b3f73 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Sat, 28 Feb 2026 00:53:44 +0000 Subject: [PATCH 06/33] refactor: cleaning the function and leave only the reusable code --- Sprint-1/fix/median.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 20e65357b..dd95f60c6 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,7 +6,13 @@ // or 'list' has mixed values (the function is expected to sort only numbers). // [...list] create a new exactly array but independent - // const sortArr = list.sort((a, b) => a - b); this modify the array +// const sortArr = list.sort((a, b) => a - b); this modify the array + +// order the array to find the middle number +//using [...list] is a safe immutable sorting +// const sortArr = [...list].sort((a, b) => a - b); + + function calculateMedian(list) { // if is not an array @@ -24,17 +30,9 @@ function calculateMedian(list) { return null; } - - // order the array to find the middle number - //using [...list] is a safe immutable sorting - // const sortArr = [...list].sort((a, b) => a - b); - // now we change to use the numsOnly otherwise will take string as numbers const sortArr = [...numsOnly].sort((a, b) => a - b); - - console.log(sortArr); - // divide the array to find the middle position. const middleIndex = Math.floor(sortArr.length / 2); From 75911357e656c27b178ae5b2da8a4e37aea4b927 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Thu, 12 Mar 2026 21:37:01 +0000 Subject: [PATCH 07/33] test: add unit tests for dedupe function with various input scenarios Co-authored-by: Joseph Ajayi --- Sprint-1/implement/dedupe.test.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 23e0f8638..aedd02097 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -2,7 +2,7 @@ const dedupe = require("./dedupe.js"); /* Dedupe Array -📖 Dedupe means **deduplicate** +📖 Dedupe means **deduplicate** In this kata, you will need to deduplicate the elements of an array @@ -16,12 +16,31 @@ E.g. dedupe([1, 2, 1]) target output: [1, 2] // Given an empty array // When passed to the dedupe function // Then it should return an empty array -test.todo("given an empty array, it returns an empty array"); +test("given an empty array, it returns an empty array", () => { + expect(dedupe([])).toEqual([]); +}); // Given an array with no duplicates // When passed to the dedupe function // Then it should return a copy of the original array +test("given an array with no duplicates, it returns a copy of the original array", () => { + expect(dedupe(["a", "b", "c"])).toEqual(["a", "b", "c"]); +}); // Given an array with strings or numbers // When passed to the dedupe function // Then it should remove the duplicate values, preserving the first occurence of each element + +describe("Describes dedupe() with duplicate values", () => { + [ + { input: [1, 2, 2, 3], expected: [1, 2, 3] }, + { input: [1, 1, 3, 4, 4, 4, 5], expected: [1, 3, 4, 5] }, + { input: ["a", "b", "a", "c"], expected: ["a", "b", "c"] }, + { input: [1, "1", 1], expected: [1, "1"] }, + { input: [5, 1, 5, 5, 2], expected: [5, 1, 2] }, + ].forEach(({ input, expected }) => { + it(`should return [${expected}] for input [${input}]`, () => { + expect(dedupe(input)).toEqual(expected); + }); + }); +}); From efb99b96e52bbe843d647bcd0837f1b2bf8747bd Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Thu, 12 Mar 2026 21:37:46 +0000 Subject: [PATCH 08/33] feat: implement deduplication function to remove duplicate values from an array --- Sprint-1/implement/dedupe.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index 781e8718a..06d3e18fc 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -1 +1,14 @@ -function dedupe() {} + + +function dedupe(val) { + if (val.length === 0) return []; + if (val.length === new Set(val).size) { + return val; + } else { + return [...new Set(val)]; + } +} + +module.exports = dedupe; + + From 5da81e2358dfb4f975bab4d40b8188b99ea54c19 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Thu, 12 Mar 2026 21:39:23 +0000 Subject: [PATCH 09/33] refactor: remove unnecessary check for empty array in dedupe function --- Sprint-1/implement/dedupe.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index 06d3e18fc..e8dfd3a3f 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -1,7 +1,6 @@ function dedupe(val) { - if (val.length === 0) return []; if (val.length === new Set(val).size) { return val; } else { From 799078c6897862a7e9d9cb8b25739c3652cc9fd6 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Thu, 12 Mar 2026 21:40:01 +0000 Subject: [PATCH 10/33] refactor: simplify dedupe function by removing unnecessary conditional check --- Sprint-1/implement/dedupe.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index e8dfd3a3f..fa22cae36 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -1,11 +1,7 @@ function dedupe(val) { - if (val.length === new Set(val).size) { - return val; - } else { - return [...new Set(val)]; - } + return [...new Set(val)]; } module.exports = dedupe; From 169e5b785385a8bae266cbd13b48be0a8e4723fa Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 16 Mar 2026 20:19:18 +0000 Subject: [PATCH 11/33] test: add unit tests for max function covering various input scenarios --- Sprint-1/implement/max.test.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index 82f18fd88..781b26361 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -5,9 +5,11 @@ In this kata, you will need to implement a function that find the largest numeri E.g. max([30, 50, 10, 40]), target output: 50 E.g. max(['hey', 10, 'hi', 60, 10]), target output: 60 (sum ignores any non-numerical elements) -You should implement this function in max.js, and add tests for it in this file. +You should implement this function in max.js, and add tests for it in this file.p We have set things up already so that this file can see your function from the other file. + +Driven Development (BDD), format Given / When / Then. */ const findMax = require("./max.js"); @@ -15,29 +17,51 @@ const findMax = require("./max.js"); // Given an empty array // When passed to the max function // Then it should return -Infinity -// Delete this test.todo and replace it with a test. -test.todo("given an empty array, returns -Infinity"); +test("should return -Infinity when given an empty array", () => { + expect(findMax([])).toEqual(-Infinity); +}); + // Given an array with one number // When passed to the max function // Then it should return that number +test("should return the number itself when the array has only one element", () => { + expect(findMax([2])).toEqual(2); +}); // Given an array with both positive and negative numbers // When passed to the max function // Then it should return the largest number overall +test("should return the largest number when given both positive and negative numbers", () => { + expect(findMax([-1, -3, 0, 3])).toEqual(3); +}); // Given an array with just negative numbers // When passed to the max function // Then it should return the closest one to zero +test("should return the closest number to zero when given only negative numbers", () => { + expect(findMax([-1, -3, -2, 0])).toEqual(-1); +}); // Given an array with decimal numbers // When passed to the max function // Then it should return the largest decimal number +test("should return the largest decimal number correctly", () => { + expect(findMax([1.5, 2.5, 0.5])).toEqual(2.5); +}); // Given an array with non-number values // When passed to the max function // Then it should return the max and ignore non-numeric values +test("should ignore non-numeric values (strings, etc.) and return the max", () => { + expect(findMax(["hey", 10, "hi", 60, 10])).toEqual(60); +}); + // Given an array with only non-number values // When passed to the max function // Then it should return the least surprising value given how it behaves for all other inputs +test("given an array with only non-number values, it returns -Infinity", () => { + expect(findMax(["abc", "def"])).toEqual(-Infinity); +}); + From 38450fd075a26bd340d0ea0112a8f41d2673db38 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 16 Mar 2026 21:26:56 +0000 Subject: [PATCH 12/33] feat: add validation for empty input and filter non-numeric values in findMax function --- Sprint-1/implement/max.js | 5 +++++ Sprint-1/implement/max.test.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/max.js b/Sprint-1/implement/max.js index 6dd76378e..7d789a459 100644 --- a/Sprint-1/implement/max.js +++ b/Sprint-1/implement/max.js @@ -1,4 +1,9 @@ function findMax(elements) { + if (elements.length === 0 || elements.every((el) => typeof el !== "number")) { + return -Infinity; + } else { + return Math.max(...elements.filter((el) => typeof el === "number")); + } } module.exports = findMax; diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index 781b26361..6594e2443 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -40,7 +40,7 @@ test("should return the largest number when given both positive and negative num // When passed to the max function // Then it should return the closest one to zero test("should return the closest number to zero when given only negative numbers", () => { - expect(findMax([-1, -3, -2, 0])).toEqual(-1); + expect(findMax([-1, -3, -2, 0])).toEqual(0); }); // Given an array with decimal numbers From 8875c3e8fd301161298465bb3f435d256a219711 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 16 Mar 2026 21:39:30 +0000 Subject: [PATCH 13/33] refactor: simplify findMax function by filtering non-numeric values --- Sprint-1/implement/max.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sprint-1/implement/max.js b/Sprint-1/implement/max.js index 7d789a459..f69d4a00b 100644 --- a/Sprint-1/implement/max.js +++ b/Sprint-1/implement/max.js @@ -1,9 +1,10 @@ +// 1. filter: leep only elements that are onlyNumbers. +// 2. spread (...) take the numbers out of the Array +// 3. Math.max find the largest number and return -infinity if empty. + function findMax(elements) { - if (elements.length === 0 || elements.every((el) => typeof el !== "number")) { - return -Infinity; - } else { - return Math.max(...elements.filter((el) => typeof el === "number")); - } + const onlyNumbers = elements.filter((element) => typeof element === "number") + return Math.max(...onlyNumbers); } module.exports = findMax; From f45cbf4a36bfccdf98bd589e19743389e5028f17 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 17 Mar 2026 18:57:29 +0000 Subject: [PATCH 14/33] test: add unit tests for sum function covering various input scenarios --- Sprint-1/implement/sum.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index dd0a090ca..438191fa6 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -13,24 +13,41 @@ const sum = require("./sum.js"); // Given an empty array // When passed to the sum function // Then it should return 0 -test.todo("given an empty array, returns 0") +test("Should return 0 for empty array", () => { + expected(sum([]).toEqual(0)); +}); // Given an array with just one number // When passed to the sum function // Then it should return that number +test("Should return the number itself for an array with one number", () => { + expected(sum([5]).toEqual(5)); +}); // Given an array containing negative numbers // When passed to the sum function // Then it should still return the correct total sum +test("Should return the correct sum even when the array contains negative numbers", () => { + expected(sum([-1, -2, -3])).toEqual(-6); +}); // Given an array with decimal/float numbers // When passed to the sum function // Then it should return the correct total sum +test("Should return the correct sum even when the array contains decimal numbers", () => { + expected(sum([1.4, 1.6, 5.8])).toEqual(8.8); +}); // Given an array containing non-number values // When passed to the sum function // Then it should ignore the non-numerical values and return the sum of the numerical elements +test("should return the sum of the numerical elements and ignore non-numerical values", () => { + expected(sum(['hey', 10, 'hi', 60, 10]).toEqual(80)); +}) // Given an array with only non-number values // When passed to the sum function // Then it should return the least surprising value given how it behaves for all other inputs +test("Should return 0 for an array with only non-numbers", () => { + expected(sum(['hey', 'hi', 'hello']).toEqual(0)); +}) From 88e8c1bfacf5e5bfcb1837db80be8ed8a7847239 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 17 Mar 2026 19:26:53 +0000 Subject: [PATCH 15/33] test: fix expected assertions in unit tests for sum function --- Sprint-1/implement/sum.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index 438191fa6..997e593ee 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -14,40 +14,40 @@ const sum = require("./sum.js"); // When passed to the sum function // Then it should return 0 test("Should return 0 for empty array", () => { - expected(sum([]).toEqual(0)); + expect(sum([])).toEqual(0); }); // Given an array with just one number // When passed to the sum function // Then it should return that number test("Should return the number itself for an array with one number", () => { - expected(sum([5]).toEqual(5)); + expect(sum([5])).toEqual(5); }); // Given an array containing negative numbers // When passed to the sum function // Then it should still return the correct total sum test("Should return the correct sum even when the array contains negative numbers", () => { - expected(sum([-1, -2, -3])).toEqual(-6); + expect(sum([-1, -2, -3])).toEqual(-6); }); // Given an array with decimal/float numbers // When passed to the sum function // Then it should return the correct total sum test("Should return the correct sum even when the array contains decimal numbers", () => { - expected(sum([1.4, 1.6, 5.8])).toEqual(8.8); + expect(sum([1.4, 1.6, 5.8])).toEqual(8.8); }); // Given an array containing non-number values // When passed to the sum function // Then it should ignore the non-numerical values and return the sum of the numerical elements test("should return the sum of the numerical elements and ignore non-numerical values", () => { - expected(sum(['hey', 10, 'hi', 60, 10]).toEqual(80)); + expect(sum(['hey', 10, 'hi', 60, 10])).toEqual(80); }) // Given an array with only non-number values // When passed to the sum function // Then it should return the least surprising value given how it behaves for all other inputs test("Should return 0 for an array with only non-numbers", () => { - expected(sum(['hey', 'hi', 'hello']).toEqual(0)); + expect(sum(['hey', 'hi', 'hello'])).toEqual(0); }) From b490a39d20bb29c0866381f1cdcc43d239b1d611 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 17 Mar 2026 19:27:32 +0000 Subject: [PATCH 16/33] feat: implement sum function with filtering for non-numeric values --- Sprint-1/implement/sum.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-1/implement/sum.js b/Sprint-1/implement/sum.js index 9062aafe3..24f514c95 100644 --- a/Sprint-1/implement/sum.js +++ b/Sprint-1/implement/sum.js @@ -1,4 +1,10 @@ function sum(elements) { + + let initialValue = 0; + const onlyNumbers = elements.filter((element) => typeof element === "number"); + let totalSum = onlyNumbers.reduce((accumulator, currentValue) => accumulator + currentValue, initialValue); + + return totalSum; } module.exports = sum; From 9e3e2a9758f6706cd28e0c60633a5dc95110b4ea Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 17 Mar 2026 19:39:42 +0000 Subject: [PATCH 17/33] refactor: simplify sum function by combining filtering and sum the number --- Sprint-1/implement/sum.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sprint-1/implement/sum.js b/Sprint-1/implement/sum.js index 24f514c95..b3141223c 100644 --- a/Sprint-1/implement/sum.js +++ b/Sprint-1/implement/sum.js @@ -1,10 +1,6 @@ function sum(elements) { - let initialValue = 0; - const onlyNumbers = elements.filter((element) => typeof element === "number"); - let totalSum = onlyNumbers.reduce((accumulator, currentValue) => accumulator + currentValue, initialValue); - - return totalSum; + return elements.reduce((acc, curr) => (typeof curr === "number" ? acc + curr : acc), 0) } module.exports = sum; From e33e09c6e94ecce3ef3f8fff6bd95dfb5665e306 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 17 Mar 2026 21:06:55 +0000 Subject: [PATCH 18/33] refactor: improve test readability and consistency in includes tests --- Sprint-1/refactor/includes.test.js | 33 ++++++++---------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/Sprint-1/refactor/includes.test.js b/Sprint-1/refactor/includes.test.js index 812158470..dd09c1bc6 100644 --- a/Sprint-1/refactor/includes.test.js +++ b/Sprint-1/refactor/includes.test.js @@ -2,37 +2,22 @@ const includes = require("./includes.js"); -test("returns true when target is in array", () => { - const currentOutput = includes(["a", "b", "c", "d"], "c"); - const targetOutput = true; - - expect(currentOutput).toEqual(targetOutput); -}); +test("Return true if the array contains the elements desired", () => { + expect(includes(["a", "b", "c", "d"], "c")).toBe(true); +}) test("returns false when target not in array", () => { - const currentOutput = includes([1, 2, 3, 4], "a"); - const targetOutput = false; - - expect(currentOutput).toEqual(targetOutput); + expect(includes([1, 2, 3, 4], "a")).toBe(false); }); test("returns true when the target is in array multiple times", () => { - const currentOutput = includes([1, 2, 2, 3], 2); - const targetOutput = true; - - expect(currentOutput).toEqual(targetOutput); + expect(includes([1, 2, 2, 3], 2)).toBe(true); }); test("returns false for empty array", () => { - const currentOutput = includes([]); - const targetOutput = false; - - expect(currentOutput).toEqual(targetOutput); + expect(includes([], "a")).toBe(false); }); -test("searches for null", () => { - const currentOutput = includes(["b", "z", null, "a"], null); - const targetOutput = true; - - expect(currentOutput).toEqual(targetOutput); -}); +test("should find null when it exists in the array", () => { + expect(includes(["b", "z", null, "a"], null)).toBe(true); +}); \ No newline at end of file From 4718ab380cd445437d5110e00bdd19c6db14e46d Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Tue, 17 Mar 2026 21:20:16 +0000 Subject: [PATCH 19/33] refactor: simplify includes function by using for...of loop --- Sprint-1/refactor/includes.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sprint-1/refactor/includes.js b/Sprint-1/refactor/includes.js index 29dad81f0..06be3020a 100644 --- a/Sprint-1/refactor/includes.js +++ b/Sprint-1/refactor/includes.js @@ -1,12 +1,11 @@ // Refactor the implementation of includes to use a for...of loop -function includes(list, target) { - for (let index = 0; index < list.length; index++) { - const element = list[index]; - if (element === target) { +function includes(list, target){ + for (const element of list){ + if (element === target){ return true; } - } + } return false; } From 57e4e9734dd117c75e6ea5a574209e2395ce1bb0 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 21:33:47 +0000 Subject: [PATCH 20/33] refactor: optimize median calculation by removing unnecessary array spread --- Sprint-1/fix/median.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index dd95f60c6..c302902c8 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -31,7 +31,7 @@ function calculateMedian(list) { } // now we change to use the numsOnly otherwise will take string as numbers - const sortArr = [...numsOnly].sort((a, b) => a - b); + const sortArr = numsOnly.sort((a, b) => a - b); // divide the array to find the middle position. const middleIndex = Math.floor(sortArr.length / 2); From b3838b56e16efe1a82161a177bc8e25effef732e Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 21:42:22 +0000 Subject: [PATCH 21/33] refactor: clean up median function by improving number filtering logic --- Sprint-1/fix/median.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index c302902c8..3007f8852 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -12,20 +12,16 @@ //using [...list] is a safe immutable sorting // const sortArr = [...list].sort((a, b) => a - b); - - -function calculateMedian(list) { - // if is not an array - if(!Array.isArray(list)){ +function calculateMedian(list) { + // if is not an array + if (!Array.isArray(list)) { return null; } - //checking only numbers and not null and empty - const numsOnly = list.filter( - (n) => typeof n === "number" && n !== null && !isNaN(n) - ); + // Filter for valid numbers only typeof n === "number"' already excludes null, strings, and objects + const numsOnly = list.filter((n) => typeof n === "number" && !isNaN(n)); - //if return numbers check if after cleaning the length is same as expected or empty + // if return numbers check if after cleaning the length is same as expected or empty if (numsOnly.length === 0) { return null; } @@ -43,7 +39,6 @@ function calculateMedian(list) { return (leftHalf + rightHalf) / 2; } return sortArr[middleIndex]; - } module.exports = calculateMedian; From 19331ebaab765e711f8e5f4b0544669130632ec0 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 22:01:23 +0000 Subject: [PATCH 22/33] fix: add new name parameter for better readability --- Sprint-1/implement/dedupe.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index fa22cae36..4258e4c49 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -1,9 +1,10 @@ +/** + * Deduplicates an array of elements (strings, numbers, etc.) + * @param {Array} items - The array containing potential duplicates + */ - -function dedupe(val) { - return [...new Set(val)]; +function dedupe(items) { + return [...new Set(items)]; } module.exports = dedupe; - - From aa28437b26094d220cd2086145a005b1b8e2b1af Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 22:14:48 +0000 Subject: [PATCH 23/33] refactor: enhance dedupe test for clarity and ensure input immutability --- Sprint-1/implement/dedupe.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 272fea4e9..35524eb99 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -24,7 +24,11 @@ test("given an empty array, it returns an empty array", () => { // When passed to the dedupe function // Then it should return a copy of the original array test("given an array with no duplicates, it returns a copy of the original array", () => { - expect(dedupe(["a", "b", "c"])).toEqual(["a", "b", "c"]); + const input = ["a", "b", "c"]; + const result = dedupe(input); + + expect(result).toEqual(input); + expect(result).not.toBe(input); }); // Given an array of strings or numbers From 788a6221c871102831095a0cbe8b565b683d9d51 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 22:42:33 +0000 Subject: [PATCH 24/33] refactor: improve number filtering logic in findMax function to exclude NaN values --- Sprint-1/implement/max.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/max.js b/Sprint-1/implement/max.js index f69d4a00b..c912dc9d0 100644 --- a/Sprint-1/implement/max.js +++ b/Sprint-1/implement/max.js @@ -3,8 +3,9 @@ // 3. Math.max find the largest number and return -infinity if empty. function findMax(elements) { - const onlyNumbers = elements.filter((element) => typeof element === "number") + const onlyNumbers = elements.filter((element) => typeof element === "number" && !Number.isNaN(element)) return Math.max(...onlyNumbers); } module.exports = findMax; + From 71807f725cbbb31f287dee724b24d966ff08320a Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 22:43:23 +0000 Subject: [PATCH 25/33] test: add cases to validate findMax function handling of NaN values --- Sprint-1/implement/max.test.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index 6594e2443..b2e7b7785 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -20,8 +20,6 @@ const findMax = require("./max.js"); test("should return -Infinity when given an empty array", () => { expect(findMax([])).toEqual(-Infinity); }); - - // Given an array with one number // When passed to the max function // Then it should return that number @@ -57,6 +55,12 @@ test("should ignore non-numeric values (strings, etc.) and return the max", () = expect(findMax(["hey", 10, "hi", 60, 10])).toEqual(60); }); +// Given an array with numbers and NaN +// When passed to the findMax function +// Then it should ignore NaN and return the largest number +test("should ignore NaN and return the max of the remaining numbers", () => { + expect(findMax([0, NaN, 1])).toEqual(1); +}); // Given an array with only non-number values // When passed to the max function @@ -65,3 +69,9 @@ test("given an array with only non-number values, it returns -Infinity", () => { expect(findMax(["abc", "def"])).toEqual(-Infinity); }); +// Given an array with only NaN values +// When passed to the findMax function +// Then it should return -Infinity +test("should return -Infinity when the array contains only NaN", () => { + expect(findMax([NaN])).toEqual(-Infinity); +}); \ No newline at end of file From c317ce7f0dc713b6a4b4471f06c5d3212a70c748 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 22:51:28 +0000 Subject: [PATCH 26/33] fix: use prettier for indentation --- Sprint-1/refactor/includes.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-1/refactor/includes.js b/Sprint-1/refactor/includes.js index 06be3020a..8c9ae2e66 100644 --- a/Sprint-1/refactor/includes.js +++ b/Sprint-1/refactor/includes.js @@ -1,11 +1,11 @@ // Refactor the implementation of includes to use a for...of loop -function includes(list, target){ - for (const element of list){ - if (element === target){ +function includes(list, target) { + for (const element of list) { + if (element === target) { return true; } - } + } return false; } From 5eb205b3a0c929402e243f74947b9f7c6641944a Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 23:06:14 +0000 Subject: [PATCH 27/33] test: add cases to validate sum function handling of NaN and Infinity values --- Sprint-1/implement/sum.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index 997e593ee..f73ec31ee 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -51,3 +51,18 @@ test("should return the sum of the numerical elements and ignore non-numerical v test("Should return 0 for an array with only non-numbers", () => { expect(sum(['hey', 'hi', 'hello'])).toEqual(0); }) + +// Given an array with NaN and numbers +// When passed to the sum function +// Then it should ignore NaN and return the sum of the numbers +test("should ignore NaN and return the correct sum", () => { + expect(sum([NaN, 1, 5])).toEqual(6); +}); + + +// Given an array with Infinity and -Infinity +// When passed to the sum function +// Then it should return NaN (standard JS behavior for infinite subtraction) +test("should return NaN when summing Infinity and -Infinity", () => { + expect(sum([Infinity, -Infinity])).toBeNaN(); +}); \ No newline at end of file From 31d489dc9118f5c77e149918634ea4abf87d8c68 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Fri, 20 Mar 2026 23:06:25 +0000 Subject: [PATCH 28/33] refactor: improve sum function to exclude NaN values during calculation --- Sprint-1/implement/sum.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/sum.js b/Sprint-1/implement/sum.js index b3141223c..0eb4f0775 100644 --- a/Sprint-1/implement/sum.js +++ b/Sprint-1/implement/sum.js @@ -1,6 +1,10 @@ function sum(elements) { - - return elements.reduce((acc, curr) => (typeof curr === "number" ? acc + curr : acc), 0) + return elements.reduce( + (acc, curr) => + typeof curr === "number" && !Number.isNaN(curr) ? acc + curr : acc, + 0 + ); } module.exports = sum; + From 1d9349db951097f1ce93bd185ae65d3c24663efe Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Mar 2026 15:54:00 +0000 Subject: [PATCH 29/33] fix: use toBeCloseTo for floating point precision and handle edge cases --- Sprint-1/implement/sum.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index f73ec31ee..0beeb069e 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -35,7 +35,7 @@ test("Should return the correct sum even when the array contains negative number // When passed to the sum function // Then it should return the correct total sum test("Should return the correct sum even when the array contains decimal numbers", () => { - expect(sum([1.4, 1.6, 5.8])).toEqual(8.8); + expect(sum([0.1, 0.2, 0.005])).toBeCloseTo(0.305); }); // Given an array containing non-number values From 81168135a191982646f341e9e3cb448f9483a47c Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Mar 2026 16:26:52 +0000 Subject: [PATCH 30/33] test: add edge cases for sum function to handle floating point precision --- Sprint-1/implement/sum.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index 0beeb069e..6d4ee4c08 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -35,9 +35,23 @@ test("Should return the correct sum even when the array contains negative number // When passed to the sum function // Then it should return the correct total sum test("Should return the correct sum even when the array contains decimal numbers", () => { - expect(sum([0.1, 0.2, 0.005])).toBeCloseTo(0.305); + expect(sum([1.4, 1.6, 5.8])).toEqual(8.8); }); +describe("sum() edge cases and floating point precision", () => { + [ + { input: [0.1, 0.2], expected: 0.3 }, + { input: [0.7, 0.2], expected: 0.9 }, + { input: [1.2, 0.6, 0.005], expected: 1.805 }, + { input: [0.005, 0.6, 1.2], expected: 1.805 }, + ].forEach(({ input, expected }) => { + it(`should return ${expected} for input [${input.join(", ")}]`, () => { + expect(sum(input)).toBeCloseTo(expected); + }); + }); +}); + + // Given an array containing non-number values // When passed to the sum function // Then it should ignore the non-numerical values and return the sum of the numerical elements From d529f184fc044613f9a56c9c386adfc548d0488d Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Mar 2026 21:17:26 +0000 Subject: [PATCH 31/33] fix: update input data for aoc-2018-day1 to correct values --- Sprint-1/stretch/aoc-2018-day1/input.txt | 1497 +++++++++++----------- 1 file changed, 771 insertions(+), 726 deletions(-) diff --git a/Sprint-1/stretch/aoc-2018-day1/input.txt b/Sprint-1/stretch/aoc-2018-day1/input.txt index 1ffa65fc8..3fad5707b 100644 --- a/Sprint-1/stretch/aoc-2018-day1/input.txt +++ b/Sprint-1/stretch/aoc-2018-day1/input.txt @@ -1,951 +1,996 @@ --10 --12 -+1 -+14 -+11 --19 --4 -+10 -+10 --12 --13 --10 --8 +-2 +-3 ++4 +-15 +-15 ++18 +-7 +11 -+3 --10 -+8 -+5 +-16 -14 -+7 -+12 -+12 ++2 +-6 ++16 ++6 +14 --1 -+17 --5 -+9 -15 -+8 --16 -+9 -+6 ++12 +-5 +17 +-10 +-20 +-19 +-14 +-10 ++4 -11 -+19 -+11 --9 ++10 -1 --8 --16 --5 -+6 -+2 -+6 +12 -+15 -+16 --6 --8 --5 -+11 --9 -+19 -+19 --5 --12 -17 --20 -+9 --6 -2 -+20 -+15 --8 -+15 -+19 --5 --17 --9 +1 --9 --11 --19 --1 --15 -+18 --4 +-17 ++9 ++4 +19 -+3 -+21 ++11 +-17 ++15 +-12 +5 ++4 -1 -+8 -+9 -+9 +-10 +-19 -16 -+17 --15 +-9 +18 -+14 -+8 ++2 ++4 +-19 ++16 ++6 +-16 +-14 ++7 +-9 ++7 ++17 ++17 +-14 ++6 +-22 -13 -2 --15 -+13 +-1 +-18 +-3 ++19 +19 --13 -+5 -+16 +16 -+7 -+8 --19 -+3 --12 -+18 --16 --19 -+8 --16 -+20 -+15 --5 --17 -+15 +-22 +14 -2 -+18 --6 -+5 -+16 -+13 +-3 ++2 +-18 +-15 +-14 +-4 +-15 ++1 +-3 -8 --9 --1 -+13 +18 --2 -+16 --4 -+19 +-11 +6 -+14 --6 --16 --10 --5 +-7 ++17 ++7 +-8 +-13 +-4 ++7 -15 -+11 -+10 -+18 -+8 --2 -+15 --9 +-11 +7 -+10 +9 --6 +-7 +1 +-20 +-19 +-18 -17 -12 -+19 -+14 --9 --18 -+20 -+12 -+10 ++7 +-16 +-11 +-4 +-8 +-4 +-3 +-2 ++3 +-15 ++18 ++5 +14 -+6 -+9 --18 -+4 +15 -+15 -+3 -+9 --4 ++2 -19 -+8 -+16 ++5 +-13 +19 --12 ++9 ++8 ++5 -1 -+16 +-19 +11 ++2 +13 --8 -+4 -+18 +-17 ++9 +-16 ++14 ++20 ++12 ++8 +10 --11 -+18 ++17 +-15 -8 ++15 +19 --4 --5 --12 +-14 -3 -10 --11 --18 --7 -+3 -+14 -+18 +2 --7 --12 -+14 -+12 -+13 --1 -+13 ++4 -1 ++14 +-12 +15 -+13 --1 --17 --4 -+17 --3 -+13 -+5 --19 -+17 -+10 -+6 --15 -+11 -+16 -+11 -+20 -+19 -+5 --11 -2 --12 --6 -11 -14 -+5 -+10 --23 +-18 ++6 +-12 ++7 ++18 ++15 ++6 ++12 ++3 +-6 ++17 ++11 +14 ++13 ++3 ++6 -11 -+22 --1 --14 --35 --23 -+11 -+4 -+10 --6 -+19 +-19 -5 -+4 --13 ++14 +-10 -7 -+11 --24 --17 -+9 ++18 +-8 +-13 +-2 ++19 +-18 -17 +11 -+2 --4 --10 --24 +14 ++17 ++1 ++26 ++6 +15 -+19 -+7 --2 -+11 --13 --8 --8 --14 --17 ++21 +-5 ++12 +6 -+8 --16 --18 -+1 --21 --14 -+8 --2 -+20 --19 -+9 --15 --6 --7 +4 --3 ++10 -8 +16 +-14 ++4 +-1 ++17 +-15 +-23 +15 --26 +18 --22 --16 --3 --17 ++19 ++10 -18 -+4 -+5 -+3 --1 -+3 -+2 -+3 -+7 --5 -+20 --11 +-2 ++15 +15 --6 --19 --24 --6 --20 +13 --4 ++5 ++10 +-8 ++2 -18 ++13 +15 -+9 -+16 -+12 --5 -+16 -+9 --4 --14 --9 ++8 -19 --5 --16 --16 -+5 ++2 -4 +-3 ++20 +-3 +12 ++6 ++13 ++13 -15 --15 --14 -+4 --18 --12 --4 +6 -+9 --12 -+14 -+9 --6 +-15 +3 -+8 -+4 +7 --14 --15 --18 -+12 -19 --14 --15 --16 ++11 ++17 +15 --8 -+14 -4 --21 -+7 --12 --2 -10 --6 -+14 -+14 --9 -14 --16 -+2 +-20 ++18 +-11 +-17 ++8 ++12 ++3 +-11 +7 -+5 --15 --15 +-13 +-4 +19 --16 --5 --16 --19 +-7 +-17 ++12 +9 --27 ++13 ++7 +-13 ++24 +-2 ++14 +-5 ++10 +-6 +-1 -8 -+6 -+1 +-5 +-6 ++5 ++12 ++16 ++5 -14 ++19 ++18 -9 --50 +-6 +-12 +-2 ++19 +-12 -9 --21 +5 --20 --19 -+6 --11 -+6 -+1 --17 --14 --2 -+8 -4 -+16 -+1 --3 --9 -+20 -+15 --22 --3 --13 --12 --25 -+5 --13 --2 --8 --11 -+17 -+3 --7 -+13 -+1 -+18 --13 -+1 -+7 --15 --43 --6 --10 --9 --20 --7 --8 --15 -9 -+13 -9 -+24 -+13 -+5 --8 --15 --4 --4 --4 --14 --21 +16 -+15 +-19 -14 +-7 +-24 -20 --20 --15 --19 --41 +16 -+3 -+8 --22 --30 -+8 -+40 -+15 -+24 --7 -+22 -+10 -+15 ++12 ++19 ++20 +-15 ++26 ++21 +-2 ++12 ++4 +-2 ++18 +-17 +-12 +-20 ++2 +9 -+28 +14 -+2 ++16 ++12 +-9 +14 -+6 +17 -+1 -+30 -+5 --2 -+46 -+24 -+46 +-19 ++11 ++3 +-13 -3 --7 -+35 -+16 -+13 --21 -+28 -+13 --25 -+180 -+25 -+5 --9 -+23 --5 --2 -+13 --12 -+2 --25 --5 ++11 +-14 +18 --24 -+45 -+17 --7 -+22 --152 --11 -+4 -+50 -+129 --7 -+22 -+109 --56 -+80 -+29 --75060 ++9 +-16 -2 --14 ++19 +7 --17 --5 -+6 +-10 -3 -+18 ++4 ++10 ++15 +19 --14 --12 --6 -+9 +-2 -5 --13 --6 --3 --15 -+13 -+3 --18 ++2 ++2 +-11 ++6 +-17 -11 ++6 +-10 +16 ++7 +-1 -2 -+10 --14 --7 +19 --20 -+15 -+10 -+12 -+10 ++6 +16 --11 -+14 --5 +-12 +14 -+11 -5 ++19 +-12 +1 --13 -+1 -+18 +-6 +-6 +-2 ++7 ++19 ++17 +-4 ++3 ++3 ++17 ++16 +-2 -10 -+25 -+13 +-1 +-14 +-2 -17 +-11 ++3 +-21 +15 ++11 ++7 +-3 -18 +1 --6 --12 -+5 --7 -+18 --6 --18 --17 --5 --15 --1 -15 +-11 +1 --12 +-18 ++11 ++15 +-17 +-16 +-19 +9 +-5 +16 -+8 +-18 ++13 ++16 +-17 +-1 +-3 +-2 ++20 ++14 +-13 +-17 ++13 +5 -+1 -+9 -+18 ++2 ++19 ++22 +-3 +-22 ++10 -13 --30 --27 --19 +2 +-29 +-27 -16 --19 --10 --18 -+21 ++17 +-27 +18 +-13 +-4 ++6 -5 -+14 -+9 ++12 +-16 +-9 ++3 ++1 ++10 +-25 +-1 +-19 ++13 ++12 ++2 -6 +-12 ++3 ++25 ++28 +-4 +2 ++17 +-9 ++63 ++23 +-8 ++9 +-6 ++15 +-14 ++12 ++6 ++18 +-6 +-15 ++12 -16 --11 +-3 ++15 ++24 ++19 +-6 ++4 +-8 +-19 ++4 ++4 +-20 +-1 ++24 ++10 +-9 ++13 ++11 ++2 ++11 ++14 +-2 ++18 +-12 +1 +-17 ++6 ++1 +-16 ++10 ++4 ++9 +-6 ++10 +-14 +-2 ++22 ++2 ++6 ++10 +-19 +-24 ++10 ++11 ++14 ++2 ++5 +18 --4 -+19 ++29 ++1 ++20 +7 -+6 --8 ++3 +-12 +25 --50 -+6 -21 ++24 ++4 +-18 ++1 ++51 ++19 +-17 +-23 ++31 +-15 ++27 ++2 ++19 +-16 ++1 ++18 ++9 ++22 +6 ++15 +-19 ++14 +-7 ++3 ++14 +-7 +-15 ++18 +-8 +-1 +-14 +-7 +-16 ++22 ++22 -2 ++18 ++2 +-15 +-39 ++5 ++21 +-5 +-2 ++4 ++1 ++9 +-58 ++6 +-95 +-85 +-5 ++1 ++7 ++9 ++15 +-117 +-12 +-14 +-18 ++70 ++9 +-17 ++93 +-37 +-134 +-90 ++22 +-19 +-7 +-59 +14 --11 -+10 +-13 +-47 ++213 ++81022 ++9 ++5 ++4 +-3 +-16 +-2 ++4 ++2 ++5 +-12 -9 -+16 -+25 --61 --17 +-13 ++2 +-18 +-18 -14 ++7 ++18 +-19 +13 -+3 --14 --4 -1 +-6 +9 -1 +-18 ++15 +-14 -4 --5 -+7 --15 -+7 ++12 +-1 ++5 +16 +-7 ++12 +6 --2 --11 --11 --13 -+11 --12 --13 --8 +-16 ++13 ++10 +3 +-11 -13 ++6 +-7 +16 ++3 +-6 ++19 +-15 ++14 -1 ++19 ++19 ++13 +-9 +-3 +-10 -14 ++15 +-9 +19 -+4 +-6 +10 -+12 -+26 +-7 ++11 +-1 ++3 ++2 +-3 ++8 ++3 ++13 +6 -+4 -+24 --31 -+9 --10 --23 --13 +3 --18 --9 --6 -+1 --2 -+15 --10 --17 ++2 ++18 ++9 -17 ++13 +15 +-13 +9 -+4 -+19 --4 -+12 -+11 --25 -+16 -+4 --2 -+39 -+49 -+9 -+96 -+4 ++2 +19 -+3 -+11 -+25 +14 -+11 +-13 ++8 ++18 ++6 +-4 +-18 ++1 +-19 +-1 ++10 -5 --26 --8 +-11 +-10 -16 -+11 -+2 -+2 --1 +-4 +-5 ++3 +-13 +-19 +-18 ++16 ++16 +-5 ++16 -10 --45 --160 --31 +-8 ++9 ++14 ++1 ++9 -3 --43 --18 +19 -+3 -+4 +-12 +11 ++12 ++5 ++19 +-9 ++4 ++15 ++19 +-4 +-10 +-12 +-18 -16 --19 --22 -+6 -+2 -+10 --11 --17 -+7 ++13 +-4 +-16 +-14 +-15 ++18 +1 -+15 -+17 --19 -+6 --26 +-8 -7 --9 -+19 +-18 ++3 +-21 ++9 +-7 ++8 ++18 +2 +-11 +6 --22 ++10 ++9 ++11 +-21 ++19 ++4 +2 --8 -+5 +7 -+9 -+8 ++10 -16 -+2 --19 --19 --3 ++13 ++9 ++9 +16 -+5 -+4 --18 ++9 ++13 -11 --19 +16 --15 -+7 --1 --9 --19 ++10 ++14 ++13 +-5 +-10 +-16 +-2 +-2 ++6 ++19 ++1 +-16 ++14 +-13 ++3 +-5 +-4 ++12 +-5 ++22 +11 --17 -5 -+7 ++13 ++4 ++13 ++19 ++18 +-13 ++15 ++19 +-12 -11 -+16 -19 +-12 +5 -+21 +-19 ++18 +-19 ++5 +-13 +-10 ++15 +-8 +-2 -2 +-11 +-6 ++5 +-4 ++21 ++18 +-5 ++18 +-11 ++19 +12 +-5 ++4 +-16 +-10 ++11 +-16 ++13 ++11 +-1 ++15 ++4 ++13 +-15 +14 -7 -+18 --8 -+10 --11 --17 -+3 --13 +19 --3 +10 -+17 -+17 --18 -+7 --2 --2 -+12 --6 +-8 +19 --20 --15 --11 --27 -+8 -+18 -+9 --1 --2 ++4 +-7 +19 -+7 -+12 -+32 ++8 +14 -+13 --9 --14 -+20 -+18 --4 --49 --6 --10 -7 --4 ++3 ++13 ++19 -9 --6 --37 --21 --2 -+5 -+12 +4 --33 --4 --13 --4 -+13 +-17 -19 --7 +-11 +-11 +-4 -16 --1 --1 -+8 --14 --15 -+11 --10 --14 --22 +-21 +-5 ++1 ++16 -11 -+10 --3 -+7 -+9 -15 -+16 +-18 +-13 +-7 +-13 +-21 +-18 ++10 ++14 ++13 -7 -1 -+2 +-4 ++17 +20 -+11 --1 -+6 --2 ++12 +-24 +3 +-8 +3 -+2 --20 --10 ++10 +11 --10 ++11 +-16 +13 --1 -+20 -+7 ++12 ++19 +-2 +7 ++6 +5 -+1 -+4 --13 ++3 ++10 +15 --3 +2 --4 --3 ++11 ++14 +-9 -1 -+13 --15 --14 --2 --6 -+3 -+13 -19 --11 -+8 --21 --2 --23 --18 -+20 -+7 +-16 ++9 ++17 +-13 ++4 +6 --28 -+7 --33 ++2 +13 --16 --18 --10 --18 ++16 ++19 ++12 ++1 ++18 ++17 ++19 ++5 +-8 ++6 ++10 ++16 +-9 +13 -+8 --14 --13 --2 +-8 +-9 ++5 +-12 +-7 +-16 +4 --14 +-12 ++18 +-19 -7 ++2 ++2 +-19 ++10 ++19 ++9 +-6 -18 --20 --4 --5 -+8 ++4 ++18 +-11 +-13 +-11 +-16 ++3 -4 -+16 -+21 -+20 --8 --14 +-11 -2 ++10 -14 --22 ++16 +14 -+36 -+32 --28 +-1 ++2 +1 --21 -+8 -+14 -+75784 \ No newline at end of file ++4 +-9 ++17 +-5 +-14 +-15 +-13 ++16 +-8 +-11 ++2 ++19 ++23 ++15 +-13 ++20 ++3 ++7 ++9 ++17 ++10 +-11 +-19 +-19 ++9 +-17 ++12 +-20 +-22 ++16 +-9 +-18 +-10 +-9 +-81046 \ No newline at end of file From c55acc133035c5bcb2a638be633bf2ba0fd6c985 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Mar 2026 22:26:13 +0000 Subject: [PATCH 32/33] fix: dedupe test for clarity and ensure input immutability --- Sprint-1/implement/dedupe.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 35524eb99..44a6a3c9c 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -27,8 +27,9 @@ test("given an array with no duplicates, it returns a copy of the original array const input = ["a", "b", "c"]; const result = dedupe(input); - expect(result).toEqual(input); - expect(result).not.toBe(input); + expect(result).toEqual(["a", "b", "c"]); // Check that the result is correct + expect(input).toEqual(["a", "b", "c"]); // Check that the original input array is unchanged + expect(result).not.toBe(input); // Check that the result has created a new array (not the same reference as input) }); // Given an array of strings or numbers From 4e2a40597ac37b34e474215a2df8b916216ed756 Mon Sep 17 00:00:00 2001 From: "Karla G." Date: Mon, 23 Mar 2026 22:26:54 +0000 Subject: [PATCH 33/33] fix: test ignore no numeric values --- Sprint-1/implement/max.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index b2e7b7785..a882c9dfc 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -55,6 +55,16 @@ test("should ignore non-numeric values (strings, etc.) and return the max", () = expect(findMax(["hey", 10, "hi", 60, 10])).toEqual(60); }); +// given an array with non-numeric values +// When passed to the max function +// Then it should strictly ignore non-numeric values, including numeric strings like '300' +test("should strictly ignore non-numeric values, including numeric strings like '300'", () => { + const input = ["hey", 10, "300", 60, 10]; + const result = findMax(input); + + expect(result).toEqual(60); // Check that the result is correct +}); + // Given an array with numbers and NaN // When passed to the findMax function // Then it should ignore NaN and return the largest number