From c9145dfc0a9be944a44642f290176cd6a3fffe52 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 16 Jul 2026 20:57:19 +0100 Subject: [PATCH 01/37] CalculateMedian function implemented --- Sprint-1/fix/median.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index b22590bc6..8b942a384 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,9 +6,16 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { + for (let i = 0; i < list.length; i++) { + if (typeof list[i] === "number" && typeof list[i] === " ") { + return null; + } const middleIndex = Math.floor(list.length / 2); const median = list.splice(middleIndex, 1)[0]; return median; } +} +let nums = [1, 2, 3]; +console.log(calculateMedian(nums)); module.exports = calculateMedian; From 1cf01db33917126bc42de35c6a6f4768590f6276 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 16 Jul 2026 20:58:11 +0100 Subject: [PATCH 02/37] Comment updated on return null --- Sprint-1/fix/median.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 8b942a384..822c398b5 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -7,8 +7,8 @@ function calculateMedian(list) { for (let i = 0; i < list.length; i++) { - if (typeof list[i] === "number" && typeof list[i] === " ") { - return null; + if (typeof list[i] === "number" && typeof list[i] === " ") { // List is checked whether it is numbers and strings. + return null; // Null is returned if list is not numbers or has mixed values(numbers and strings) } const middleIndex = Math.floor(list.length / 2); const median = list.splice(middleIndex, 1)[0]; From 256ef50be642483dee5284a511cdcdc005e71358 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 16 Jul 2026 23:01:36 +0100 Subject: [PATCH 03/37] Function calculateMedian updated so it could calculate even elements of arrays. --- Sprint-1/fix/median.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 822c398b5..561e70090 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -7,15 +7,17 @@ function calculateMedian(list) { for (let i = 0; i < list.length; i++) { - if (typeof list[i] === "number" && typeof list[i] === " ") { // List is checked whether it is numbers and strings. - return null; // Null is returned if list is not numbers or has mixed values(numbers and strings) + if (typeof list[i] === "number" && typeof list[i] === " ") { + // List is checked whether it is numbers and strings. + return null; // Null is returned if list is not numbers or has mixed values(numbers and strings) + } + const middleIndex = Math.floor(list.length / 2); + + if (list.length % 2 === 0) { + return (list[middleIndex - 1] + list[middleIndex]) / 2; + } + return list[middleIndex]; } - const middleIndex = Math.floor(list.length / 2); - const median = list.splice(middleIndex, 1)[0]; - return median; -} } -let nums = [1, 2, 3]; -console.log(calculateMedian(nums)); module.exports = calculateMedian; From 973df9183eb199b3914b6b9318a71f4303964343 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 18 Jul 2026 22:30:59 +0100 Subject: [PATCH 04/37] findMax function implemented to check for the largest number in a given array. --- Sprint-1/implement/max.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/implement/max.js b/Sprint-1/implement/max.js index 6dd76378e..cc5ff8039 100644 --- a/Sprint-1/implement/max.js +++ b/Sprint-1/implement/max.js @@ -1,4 +1,11 @@ function findMax(elements) { + let largestNum = []; + for (let i = 0; i <= elements.length; i++) { + if (elements[i] > largestNum) { + largestNum = elements[i]; + } + } + return largestNum; } module.exports = findMax; From 535f62f99bf3b6e221ebb0be6711812776648340 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 20 Jul 2026 19:53:33 +0100 Subject: [PATCH 05/37] first test case for an empty array input written, tested and passed. --- Sprint-1/implement/dedupe.test.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index d7c8e3d8e..764385bc9 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -16,13 +16,18 @@ E.g. dedupe([1, 2, 1]) returns [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.todo("given an empty array, it returns an empty array"); +test("given an empty array, it returns an empty array", function() { + console.log(dedupe) + 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 // Given an array of strings or numbers -// When passed to the dedupe function +// When passed to the dedupe function // Then it should return a new array with duplicates removed while preserving the // first occurrence of each element from the original array. From ff4538c26147693012f3d7fbdfa9141156799800 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 20 Jul 2026 19:54:53 +0100 Subject: [PATCH 06/37] Dedupe function implemented to return an empty array. --- Sprint-1/implement/dedupe.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index 781e8718a..b37e7ae75 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -1 +1,5 @@ -function dedupe() {} +function dedupe(arr) { + if (arr.length === 0) return arr; +} + +module.exports = dedupe; \ No newline at end of file From f713ab1f64e4e5437120730692177913aa546ef9 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 21 Jul 2026 15:12:45 +0100 Subject: [PATCH 07/37] Array copied and sorted. Array checked for non numeric array --- Sprint-1/fix/median.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 561e70090..6ff55c8b3 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,18 +6,26 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - for (let i = 0; i < list.length; i++) { - if (typeof list[i] === "number" && typeof list[i] === " ") { + //for (let i = 0; i < list.length; i++) { + //if (typeof list[i] !== "number" && typeof list[i] === " ") { // List is checked whether it is numbers and strings. - return null; // Null is returned if list is not numbers or has mixed values(numbers and strings) - } - const middleIndex = Math.floor(list.length / 2); + //return null; // Null is returned if list is not numbers or has mixed values(numbers and strings) + //} + + if (!Array.isArray(list) || list.length === 0) { + return null; + } - if (list.length % 2 === 0) { - return (list[middleIndex - 1] + list[middleIndex]) / 2; - } - return list[middleIndex]; + const newArray = [...list]; + newArray.sort((a, b) => a - b); + const middleIndex = Math.floor(newArray.length / 2); + // const median = list.splice(middleIndex, 1)[0]; + //return median; + + if (newArray.length % 2 === 0) { + return (newArray[middleIndex - 1] + newArray[middleIndex]) / 2; } + return newArray[middleIndex]; } - +console.log(calculateMedian([3, 1, 2])); module.exports = calculateMedian; From 022321e47f6485eb8f83fd1a3918dae794b8587f Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 21 Jul 2026 15:15:19 +0100 Subject: [PATCH 08/37] Tested for unsorted array and not an array. --- Sprint-1/fix/median.test.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/Sprint-1/fix/median.test.js b/Sprint-1/fix/median.test.js index 21da654d7..03ca6b0d4 100644 --- a/Sprint-1/fix/median.test.js +++ b/Sprint-1/fix/median.test.js @@ -13,7 +13,8 @@ describe("calculateMedian", () => { { input: [1, 2, 3, 4], expected: 2.5 }, { input: [1, 2, 3, 4, 5, 6], expected: 3.5 }, ].forEach(({ input, expected }) => - it(`returns the median for [${input}]`, () => expect(calculateMedian(input)).toEqual(expected)) + it(`returns the median for [${input}]`, () => + expect(calculateMedian(input)).toEqual(expected)) ); [ @@ -24,19 +25,29 @@ describe("calculateMedian", () => { { input: [110, 20, 0], expected: 20 }, { input: [6, -2, 2, 12, 14], expected: 6 }, ].forEach(({ input, expected }) => - it(`returns the correct median for unsorted array [${input}]`, () => expect(calculateMedian(input)).toEqual(expected)) + it(`returns the correct median for unsorted array [${input}]`, () => + expect(calculateMedian(input)).toEqual(expected)) ); - - it("doesn't modify the input array [3, 1, 2]", () => { + it("doesn't modify the input array [3, 1, 2]", () => { const list = [3, 1, 2]; calculateMedian(list); expect(list).toEqual([3, 1, 2]); }); - - [ 'not an array', 123, null, undefined, {}, [], ["apple", null, undefined] ].forEach(val => - it(`returns null for non-numeric array (${val})`, () => expect(calculateMedian(val)).toBe(null)) + + [ + "not an array", + 123, + null, + undefined, + {}, + [], + ["apple", null, undefined], + ].forEach((val) => + it(`returns null for non-numeric array (${val})`, () => + expect(calculateMedian(val)).toBe(null)) ); - +}); +/* [ { input: [1, 2, "3", null, undefined, 4], expected: 2 }, { input: ["apple", 1, 2, 3, "banana", 4], expected: 2.5 }, @@ -45,6 +56,7 @@ describe("calculateMedian", () => { { input: [3, "apple", 1, null, 2, undefined, 4], expected: 2.5 }, { input: ["banana", 5, 3, "apple", 1, 4, 2], expected: 3 }, ].forEach(({ input, expected }) => - it(`filters out non-numeric values and calculates the median for [${input}]`, () => expect(calculateMedian(input)).toEqual(expected)) - ); -}); + it(`filters out non-numeric values and calculates the median for [${input}]`, () => + expect(calculateMedian(input)).toEqual(expected)) + );*/ + From 3234e577da7aa96d9b3e88991acfb11f27f3bedc Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 21 Jul 2026 20:17:07 +0100 Subject: [PATCH 09/37] If statement for filtering through non numeric value implemented for the last set of test. --- Sprint-1/fix/median.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 6ff55c8b3..7a8a59e8b 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,26 +6,21 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - //for (let i = 0; i < list.length; i++) { - //if (typeof list[i] !== "number" && typeof list[i] === " ") { - // List is checked whether it is numbers and strings. - //return null; // Null is returned if list is not numbers or has mixed values(numbers and strings) - //} - - if (!Array.isArray(list) || list.length === 0) { + if (!Array.isArray(list) || list.length === 0) { return null; - } + } + + const numbers = list.filter((item) => typeof item === "number"); + if (numbers.length === 0) { + return null; + } - const newArray = [...list]; - newArray.sort((a, b) => a - b); - const middleIndex = Math.floor(newArray.length / 2); - // const median = list.splice(middleIndex, 1)[0]; - //return median; + numbers.sort((a, b) => a - b); + const middleIndex = Math.floor(numbers.length / 2); - if (newArray.length % 2 === 0) { - return (newArray[middleIndex - 1] + newArray[middleIndex]) / 2; + if (numbers.length % 2 === 0) { + return (numbers[middleIndex - 1] + numbers[middleIndex]) / 2; } - return newArray[middleIndex]; + return numbers[middleIndex]; } -console.log(calculateMedian([3, 1, 2])); module.exports = calculateMedian; From e60e7e12739b4e742313cb7bc646e6b8bdfc52f5 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 21 Jul 2026 20:18:22 +0100 Subject: [PATCH 10/37] Test for filtering out non-numeric values and calculates the median tested and passed. --- Sprint-1/fix/median.test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sprint-1/fix/median.test.js b/Sprint-1/fix/median.test.js index 03ca6b0d4..604c2f351 100644 --- a/Sprint-1/fix/median.test.js +++ b/Sprint-1/fix/median.test.js @@ -46,8 +46,7 @@ describe("calculateMedian", () => { it(`returns null for non-numeric array (${val})`, () => expect(calculateMedian(val)).toBe(null)) ); -}); -/* + [ { input: [1, 2, "3", null, undefined, 4], expected: 2 }, { input: ["apple", 1, 2, 3, "banana", 4], expected: 2.5 }, @@ -58,5 +57,4 @@ describe("calculateMedian", () => { ].forEach(({ input, expected }) => it(`filters out non-numeric values and calculates the median for [${input}]`, () => expect(calculateMedian(input)).toEqual(expected)) - );*/ - + )}); From 15d96c8779ecfff7b1d7276017606bcd17799998 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 11:40:39 +0100 Subject: [PATCH 11/37] Test case for non duplicate array created. --- Sprint-1/implement/dedupe.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 764385bc9..fdda16c57 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -26,8 +26,18 @@ test("given an empty array, it returns an empty array", function() { // Given an array with no duplicates // When passed to the dedupe function // Then it should return a copy of the original array +test("given non duplicate array, it returns a copy of the array", function () { + const array = [1, 2, 3]; + const result = dedupe(array); + expect(result()).toEqual(array); +}); // Given an array of strings or numbers // When passed to the dedupe function // Then it should return a new array with duplicates removed while preserving the // first occurrence of each element from the original array. +test("given an empty array, it returns an empty array", function () { + const array = [1, 2, 3]; + const result = dedupe(array); + expect(result()).toEqual(array); +}); \ No newline at end of file From d336151275b8810b61cbf446e1f3f40141c1bec4 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 20:33:52 +0100 Subject: [PATCH 12/37] Test for mixed numbers and strings created. --- Sprint-1/implement/dedupe.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index fdda16c57..ca89d95b2 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -36,8 +36,8 @@ test("given non duplicate array, it returns a copy of the array", function () { // When passed to the dedupe function // Then it should return a new array with duplicates removed while preserving the // first occurrence of each element from the original array. -test("given an empty array, it returns an empty array", function () { - const array = [1, 2, 3]; +test("given an array with, it returns an empty array", function () { + const array = [1, c, 2, 3, d]; const result = dedupe(array); expect(result()).toEqual(array); }); \ No newline at end of file From f075a6e9186a7a82928a5a5994b1909125dcb2f7 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 20:56:19 +0100 Subject: [PATCH 13/37] Function implemented to check for duplicate elements in a given array. --- Sprint-1/implement/dedupe.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index b37e7ae75..c27f9265e 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -1,5 +1,13 @@ function dedupe(arr) { - if (arr.length === 0) return arr; + const elements = []; + for (const item of arr) { + if (!elements.includes(item)) { + elements.push(item); + } + } + return elements; } +console.log(dedupe([1, 2, 2, 3, 4, 4, 5, 6])); + +module.exports = dedupe; -module.exports = dedupe; \ No newline at end of file From 3b5f6cdaba845f460a822616a8b0f3a61f62617b Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 21:19:26 +0100 Subject: [PATCH 14/37] Brackets removed from the second test inside expect. --- .gitignore | 9 +++++++++ Sprint-1/implement/dedupe.js | 6 ++++-- Sprint-1/implement/dedupe.test.js | 2 +- Sprint-2/implement/contains.test.js | 17 ++++++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8ee70353f..3cf3b0a14 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,12 @@ node_modules **/.DS_Store .idea package-lock.json +prep/query-string-test.js +prep/newarray.js +prep/median1.js +prep/mean1.test.js +prep/mean1.js +prep/meadian2.js +prep/meadian1.test.js +prep/example2.js +prep/example.js diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index c27f9265e..6a239e400 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -5,9 +5,11 @@ function dedupe(arr) { elements.push(item); } } + if (elements.length === arr.length) { + return arr.slice(); + } return elements; } -console.log(dedupe([1, 2, 2, 3, 4, 4, 5, 6])); +//console.log(dedupe([1, 2, 2, 3, 4, 4, 5, 6])); module.exports = dedupe; - diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index ca89d95b2..6129e25b7 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -29,7 +29,7 @@ test("given an empty array, it returns an empty array", function() { test("given non duplicate array, it returns a copy of the array", function () { const array = [1, 2, 3]; const result = dedupe(array); - expect(result()).toEqual(array); + expect(result).toEqual(array); }); // Given an array of strings or numbers diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 326bdb1f2..d3dca7067 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -16,20 +16,35 @@ as the object doesn't contains a key of 'c' // Given a contains function // When passed an object and a property name // Then it should return true if the object contains the property, false otherwise +test("contains on object and property returns true", () => { + expect(contains({}, )).toBe(true); +}); // Given an empty object // When passed to contains // Then it should return false -test.todo("contains on empty object returns false"); +//test.todo("contains on empty object returns false"); +test("contains on empty object returns false", () => { + expect(contains({}, )).toBe(false); +}); // Given an object with properties // When passed to contains with an existing property name // Then it should return true +test("contains on object and property returns true", () => { + expect(contains({}, )).toBe(true); +}); // Given an object with properties // When passed to contains with a non-existent property name // Then it should return false +test("contains on a non-existent property name returns false", () => { + expect(contains({}, )).toBe(false); +}); // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error +test("contains on invalid parameters returns false", () => { + expect(contains({}, )).toBe(false); +}); From 455f1b88f117655d2a96d4712f19b2882f843c75 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 21:29:25 +0100 Subject: [PATCH 15/37] last tested fixed by putting strings inside quotes. --- Sprint-1/implement/dedupe.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 6129e25b7..7e4db5ff2 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -37,7 +37,7 @@ test("given non duplicate array, it returns a copy of the array", function () { // Then it should return a new array with duplicates removed while preserving the // first occurrence of each element from the original array. test("given an array with, it returns an empty array", function () { - const array = [1, c, 2, 3, d]; + const array = [1, "c", 2, 3, "d"]; const result = dedupe(array); - expect(result()).toEqual(array); + expect(result).toEqual(array); }); \ No newline at end of file From 83518789eb98c37137953a7d42b1b7f868481d92 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 21:30:52 +0100 Subject: [PATCH 16/37] console.log for removed --- 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 6a239e400..87f98a8ea 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -10,6 +10,5 @@ function dedupe(arr) { } return elements; } -//console.log(dedupe([1, 2, 2, 3, 4, 4, 5, 6])); module.exports = dedupe; From dccd5c52e16ab46f1523d7cf4f6667b2a2df6f7a Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 22:17:59 +0100 Subject: [PATCH 17/37] Description of the last test updated. --- Sprint-1/implement/dedupe.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 7e4db5ff2..6961e3d88 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -36,7 +36,7 @@ test("given non duplicate array, it returns a copy of the array", function () { // When passed to the dedupe function // Then it should return a new array with duplicates removed while preserving the // first occurrence of each element from the original array. -test("given an array with, it returns an empty array", function () { +test("given an array of strings or numbers, it returns the original occurrence of the array", function () { const array = [1, "c", 2, 3, "d"]; const result = dedupe(array); expect(result).toEqual(array); From c31c00aaebbe2c2d7123af44dcf4bdacfe7bf3b2 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 22 Jul 2026 22:19:19 +0100 Subject: [PATCH 18/37] First test case for checking an array with one number created. --- Sprint-1/implement/max.test.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index 82f18fd88..1db008a86 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -16,11 +16,18 @@ const findMax = require("./max.js"); // 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("given an empty array, returns -Infinity", function() { + +}); // Given an array with one number // When passed to the max function // Then it should return that number +test("given an empty array, returns -Infinity", function () { + const numbers = [5]; + const maxNumber = max(numbers); + expect(maxNumber).toEqual(numbers); +}); // Given an array with both positive and negative numbers // When passed to the max function From 129f6357f4dbdaf808d2027370d0919f598296c9 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 21:29:52 +0100 Subject: [PATCH 19/37] A second if statement added for checking non numeric values and return undefined. --- Sprint-1/implement/max.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sprint-1/implement/max.js b/Sprint-1/implement/max.js index cc5ff8039..44c14d408 100644 --- a/Sprint-1/implement/max.js +++ b/Sprint-1/implement/max.js @@ -1,11 +1,12 @@ function findMax(elements) { - let largestNum = []; - for (let i = 0; i <= elements.length; i++) { - if (elements[i] > largestNum) { - largestNum = elements[i]; - } + let largestNum; + for (let i = 0; i < elements.length; i++) { + if (typeof elements[i] === "number") { + if (largestNum === undefined || elements[i] > largestNum) { + largestNum = elements[i]; + } } - return largestNum; + } + return largestNum; } - module.exports = findMax; From aa468552d34082dae4f340bba46c02cb6bb28741 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 21:30:36 +0100 Subject: [PATCH 20/37] Last test fixed for bug for testing non numeric array and return undefined. --- Sprint-1/implement/max.test.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index 1db008a86..b35f30105 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -17,34 +17,47 @@ const findMax = require("./max.js"); // Then it should return -Infinity // Delete this test.todo and replace it with a test. test("given an empty array, returns -Infinity", function() { - + expect(findMax([])).toBeUndefined(); }); // Given an array with one number // When passed to the max function // Then it should return that number -test("given an empty array, returns -Infinity", function () { - const numbers = [5]; - const maxNumber = max(numbers); - expect(maxNumber).toEqual(numbers); +test("given an array, with one number returns that number", function () { + expect(findMax([5])).toBe(5); }); // Given an array with both positive and negative numbers // When passed to the max function // Then it should return the largest number overall +test("given an array with positive and negative numbers, returns the largest", function () { + expect(findMax([(-1, -5, 1, 4)])).toBe(4); +}); // Given an array with just negative numbers // When passed to the max function // Then it should return the closest one to zero +test("given an array with negative numbers, returns the closest to zero", function () { + expect(findMax([-3, -2, -1])).toBe(-1); +}); // Given an array with decimal numbers // When passed to the max function // Then it should return the largest decimal number +test("given an empty array, returns -Infinity", function () { + expect(findMax([6.5, 1.7, 2.3])).toBe(6.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("given an array with non numeric value, returns the max ignoring the non numeric value", function () { + expect(findMax([-1, -5, 1, 4])).toBe(4); +}); // 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, returns the least surprising value", function () { + expect(findMax(["a", "b", "c"])).toBe(undefined); +}); \ No newline at end of file From c37845d02a213b284bf8a7a7a0c3f58833551e40 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 22:20:30 +0100 Subject: [PATCH 21/37] Extra brackets removed --- Sprint-1/implement/max.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/implement/max.test.js b/Sprint-1/implement/max.test.js index b35f30105..50c50c8a8 100644 --- a/Sprint-1/implement/max.test.js +++ b/Sprint-1/implement/max.test.js @@ -31,7 +31,7 @@ test("given an array, with one number returns that number", function () { // When passed to the max function // Then it should return the largest number overall test("given an array with positive and negative numbers, returns the largest", function () { - expect(findMax([(-1, -5, 1, 4)])).toBe(4); + expect(findMax([-1, -5, 1, 4])).toBe(4); }); // Given an array with just negative numbers From 763e7ce5158d36542365b04f6800e61750ebfac8 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 22:20:58 +0100 Subject: [PATCH 22/37] All required test cases created. --- Sprint-1/implement/sum.test.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index dd0a090ca..52a30163d 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -13,24 +13,42 @@ 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("given an empty array, returns 0", function() { + expect(sum([])).toBe(0); +}); // Given an array with just one number // When passed to the sum function // Then it should return that number +test("given an array with just one number, returns that number", function() { + expect(sum([1])).toBe(1); +}); // Given an array containing negative numbers // When passed to the sum function // Then it should still return the correct total sum +test("given a negative array, returns the sum", function() { + expect(sum([-5, -2, -9, -11])).toBe(-22); +}); // Given an array with decimal/float numbers // When passed to the sum function // Then it should return the correct total sum +test("given a decimal array, returns the sum", function() { + expect(sum([1.9, 3.1, 2.7])).toBe(6.7); +}); // 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("given a non-numeric array, returns the sum ignoring non-numerics", function() { + expect(sum(["c", 3, 4, "hi", 7])).toBe(14); +}); // 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("given an array of non-numeric value, returns undefined", function() { + expect(sum(["b", "hello", "y"])).toBe(undefined); +}); \ No newline at end of file From 1a697cc6847882f2e5ba69aa0a8d96bc5992e9e0 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 22:39:22 +0100 Subject: [PATCH 23/37] function implemented for checking calculating sum of numeric array --- Sprint-1/implement/sum.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-1/implement/sum.js b/Sprint-1/implement/sum.js index 9062aafe3..68d44b00d 100644 --- a/Sprint-1/implement/sum.js +++ b/Sprint-1/implement/sum.js @@ -1,4 +1,12 @@ function sum(elements) { + let sum = 0; + for (let i = 0; i < elements.length; i++) { + sum += elements[i]; + } + return sum } +let numbers = ["c", 3, 4, "hi", 7]; +console.log(sum(numbers)); + module.exports = sum; From f86b512f3b0aa33411f5d9608fa234cc4af7cd99 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 22:40:17 +0100 Subject: [PATCH 24/37] Error sums inside toBe corrected. --- Sprint-1/implement/sum.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index 52a30163d..c47fa4244 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -28,21 +28,21 @@ test("given an array with just one number, returns that number", function() { // When passed to the sum function // Then it should still return the correct total sum test("given a negative array, returns the sum", function() { - expect(sum([-5, -2, -9, -11])).toBe(-22); + expect(sum([-4, -2, -1])).toBe(-7); }); // Given an array with decimal/float numbers // When passed to the sum function // Then it should return the correct total sum test("given a decimal array, returns the sum", function() { - expect(sum([1.9, 3.1, 2.7])).toBe(6.7); + expect(sum([1.9, 3.1, 2.7])).toBe(7.7); }); // 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("given a non-numeric array, returns the sum ignoring non-numerics", function() { - expect(sum(["c", 3, 4, "hi", 7])).toBe(14); + expect(sum(["c", 3, 4, "hi", 7])).toBe(7); }); // Given an array with only non-number values From b1c125a41eb8cf31d4114a501c41b018978c8f90 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 23:31:08 +0100 Subject: [PATCH 25/37] A second if statement added to check for an array with non-numeric and empty value --- Sprint-1/implement/sum.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sprint-1/implement/sum.js b/Sprint-1/implement/sum.js index 68d44b00d..accc3696b 100644 --- a/Sprint-1/implement/sum.js +++ b/Sprint-1/implement/sum.js @@ -1,12 +1,20 @@ function sum(elements) { - let sum = 0; - for (let i = 0; i < elements.length; i++) { - sum += elements[i]; + let sum = 0; + let hasNumber = false; + + for (let i = 0; i < elements.length; i++) { + if (typeof elements[i] === "number") { + sum += elements[i]; + hasNumber = true; } - return sum + } + if (hasNumber === false && elements.length >0) { + return undefined; + } + return sum; } -let numbers = ["c", 3, 4, "hi", 7]; +let numbers = ["c", "b", "hi", 1]; console.log(sum(numbers)); module.exports = sum; From 6e687da707fa1283a1e8365e40fa9208c7a09941 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 23:32:37 +0100 Subject: [PATCH 26/37] Sum calculation errors corrected on the last test case. --- Sprint-1/implement/sum.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/implement/sum.test.js b/Sprint-1/implement/sum.test.js index c47fa4244..4f03d9936 100644 --- a/Sprint-1/implement/sum.test.js +++ b/Sprint-1/implement/sum.test.js @@ -41,8 +41,8 @@ test("given a decimal array, returns the sum", function() { // 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("given a non-numeric array, returns the sum ignoring non-numerics", function() { - expect(sum(["c", 3, 4, "hi", 7])).toBe(7); +test("given a mixed array, returns only the sum of numbers ", function() { + expect(sum(["c", 3, 4, "hi", 7])).toBe(14); }); // Given an array with only non-number values From 926ec2845a771fc9f30caaacdd24efdf853c8d85 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 30 Jul 2026 23:01:35 +0100 Subject: [PATCH 27/37] Restore untouched file to match main --- Sprint-2/implement/contains.test.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index d3dca7067..326bdb1f2 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -16,35 +16,20 @@ as the object doesn't contains a key of 'c' // Given a contains function // When passed an object and a property name // Then it should return true if the object contains the property, false otherwise -test("contains on object and property returns true", () => { - expect(contains({}, )).toBe(true); -}); // Given an empty object // When passed to contains // Then it should return false -//test.todo("contains on empty object returns false"); -test("contains on empty object returns false", () => { - expect(contains({}, )).toBe(false); -}); +test.todo("contains on empty object returns false"); // Given an object with properties // When passed to contains with an existing property name // Then it should return true -test("contains on object and property returns true", () => { - expect(contains({}, )).toBe(true); -}); // Given an object with properties // When passed to contains with a non-existent property name // Then it should return false -test("contains on a non-existent property name returns false", () => { - expect(contains({}, )).toBe(false); -}); // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error -test("contains on invalid parameters returns false", () => { - expect(contains({}, )).toBe(false); -}); From 8901c43e43b064af5836a3de19972503e674e993 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 30 Jul 2026 23:10:07 +0100 Subject: [PATCH 28/37] Restore untouched file to match main --- Sprint-1/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/readme.md b/Sprint-1/readme.md index cf282a64b..003970760 100644 --- a/Sprint-1/readme.md +++ b/Sprint-1/readme.md @@ -20,7 +20,7 @@ In this section, you'll have a function and some tests. The function isn't worki - Run the tests - to run the tests for the `fix` directory you can `cd` into `Sprint-1` and run `npm test -- fix`. - Interpret the test feedback -- Fix the function to make it pass the tests +- Fix the tests ## 🔨 Implement From 0f31552f29a69d925f347e89d5ba35ebc6a2fb20 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 30 Jul 2026 23:36:01 +0100 Subject: [PATCH 29/37] Restore untouched files to match main --- .gitignore | 9 --------- Sprint-3/alarmclock/alarmclock.js | 4 +++- Sprint-3/alarmclock/index.html | 2 +- prep/example.js | 13 +++++++++++++ 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 prep/example.js diff --git a/.gitignore b/.gitignore index 3cf3b0a14..8ee70353f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,12 +4,3 @@ node_modules **/.DS_Store .idea package-lock.json -prep/query-string-test.js -prep/newarray.js -prep/median1.js -prep/mean1.test.js -prep/mean1.js -prep/meadian2.js -prep/meadian1.test.js -prep/example2.js -prep/example.js diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..dee404c90 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,6 @@ -function setAlarm() {} +function setAlarm() { + +} // DO NOT EDIT BELOW HERE diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..ff2d3b453 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ - Title here + Alarm clock app
diff --git a/prep/example.js b/prep/example.js new file mode 100644 index 000000000..6e2302d24 --- /dev/null +++ b/prep/example.js @@ -0,0 +1,13 @@ +function doubleAllNumbers(numbers) { + let doubleNumbers = [] + + for (let n of numbers) { + doubleNumbers.push(n * 2); + } + + return doubleNumbers; +} + +const myNums = [10, 20, 30]; +console.log(doubleAllNumbers(myNums)); +console.log(myNums); From a4904af64591228aa6f9fe772537b095b16837d6 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 30 Jul 2026 23:39:00 +0100 Subject: [PATCH 30/37] Tittle changed to alarm clock app --- Sprint-3/alarmclock/alarmclock.js | 4 +--- Sprint-3/alarmclock/index.html | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index dee404c90..6ca81cd3b 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,6 +1,4 @@ -function setAlarm() { - -} +function setAlarm() {} // DO NOT EDIT BELOW HERE diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index ff2d3b453..48e2e80d9 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ - Alarm clock app + Title here
From bcb050c65b85fc2ed57cf814825a45a60e6ed078 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 30 Jul 2026 23:44:53 +0100 Subject: [PATCH 31/37] Remove file not present on main and restore readme --- prep/example.js | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 prep/example.js diff --git a/prep/example.js b/prep/example.js deleted file mode 100644 index 6e2302d24..000000000 --- a/prep/example.js +++ /dev/null @@ -1,13 +0,0 @@ -function doubleAllNumbers(numbers) { - let doubleNumbers = [] - - for (let n of numbers) { - doubleNumbers.push(n * 2); - } - - return doubleNumbers; -} - -const myNums = [10, 20, 30]; -console.log(doubleAllNumbers(myNums)); -console.log(myNums); From 01f497fea153f4548e4f8b56d7c41a253109420a Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 30 Jul 2026 23:50:52 +0100 Subject: [PATCH 32/37] Restore readme to match upstream main --- Sprint-1/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/readme.md b/Sprint-1/readme.md index 003970760..cf282a64b 100644 --- a/Sprint-1/readme.md +++ b/Sprint-1/readme.md @@ -20,7 +20,7 @@ In this section, you'll have a function and some tests. The function isn't worki - Run the tests - to run the tests for the `fix` directory you can `cd` into `Sprint-1` and run `npm test -- fix`. - Interpret the test feedback -- Fix the tests +- Fix the function to make it pass the tests ## 🔨 Implement From c8c965663c1fb655c445c4b3351e1075c08aeb3f Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 31 Jul 2026 00:00:23 +0100 Subject: [PATCH 33/37] The for loop changed into for of loop --- Sprint-1/refactor/includes.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-1/refactor/includes.js b/Sprint-1/refactor/includes.js index 29dad81f0..8c9ae2e66 100644 --- a/Sprint-1/refactor/includes.js +++ b/Sprint-1/refactor/includes.js @@ -1,8 +1,7 @@ // 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]; + for (const element of list) { if (element === target) { return true; } From 1ed419ef15049a9e84ab07e25b3eb9dca7ed0dfe Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 31 Jul 2026 00:01:12 +0100 Subject: [PATCH 34/37] test checked and passed --- Sprint-1/refactor/includes.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/refactor/includes.test.js b/Sprint-1/refactor/includes.test.js index 812158470..9b2b0bf92 100644 --- a/Sprint-1/refactor/includes.test.js +++ b/Sprint-1/refactor/includes.test.js @@ -36,3 +36,4 @@ test("searches for null", () => { expect(currentOutput).toEqual(targetOutput); }); +// test checked and passed. \ No newline at end of file From 2b687ea6a6e060b4679edc631aba80d68c1243eb Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 1 Aug 2026 18:13:47 +0100 Subject: [PATCH 35/37] Unnecessary if statement deleted. --- Sprint-1/implement/dedupe.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sprint-1/implement/dedupe.js b/Sprint-1/implement/dedupe.js index 87f98a8ea..d2a90f033 100644 --- a/Sprint-1/implement/dedupe.js +++ b/Sprint-1/implement/dedupe.js @@ -5,9 +5,6 @@ function dedupe(arr) { elements.push(item); } } - if (elements.length === arr.length) { - return arr.slice(); - } return elements; } From 852aa339c76401f627c8d368bf6baa5600b1aba0 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 1 Aug 2026 18:15:21 +0100 Subject: [PATCH 36/37] Console.log removed that was used for test --- Sprint-1/implement/sum.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sprint-1/implement/sum.js b/Sprint-1/implement/sum.js index accc3696b..5e7063344 100644 --- a/Sprint-1/implement/sum.js +++ b/Sprint-1/implement/sum.js @@ -14,7 +14,4 @@ function sum(elements) { return sum; } -let numbers = ["c", "b", "hi", 1]; -console.log(sum(numbers)); - module.exports = sum; From bb527b5de0dabb1cf7ecdf6b5ab31d98b28b8a97 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 1 Aug 2026 18:20:35 +0100 Subject: [PATCH 37/37] Not needed code removed --- Sprint-1/implement/dedupe.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 6961e3d88..1f8fdf99d 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -18,9 +18,7 @@ E.g. dedupe([1, 2, 1]) returns [1, 2] // 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", function() { - console.log(dedupe) expect(dedupe([])).toEqual([]); - }); // Given an array with no duplicates