From c9145dfc0a9be944a44642f290176cd6a3fffe52 Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 16 Jul 2026 20:57:19 +0100 Subject: [PATCH 01/47] 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/47] 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/47] 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 84b5c1ecc457fd5d8945cf36f0480b872e00fdcb Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 18 Jul 2026 22:08:29 +0100 Subject: [PATCH 04/47] .houseNumber added in order to the house number to be printed. --- Sprint-2/debug/address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 940a6af83..36d2f865d 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -12,4 +12,4 @@ const address = { postcode: "XYZ 123", }; -console.log(`My house number is ${address[0]}`); +console.log(`My house number is ${address.houseNumber}`); From 51f62a2852ac8661d37339c6895aaf450770d5ff Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 19 Jul 2026 22:46:29 +0100 Subject: [PATCH 05/47] Author object for of loop changed into for in tp print al the values of the object. --- Sprint-2/debug/author.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-2/debug/author.js b/Sprint-2/debug/author.js index 8c2125977..419780a78 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -11,6 +11,9 @@ const author = { alive: true, }; -for (const value of author) { - console.log(value); +for (const value in author) { + console.log(author[value]); } + +// The for of loop is trying to iterate through the object like an array. +// For in loop would work better. \ No newline at end of file From ae0b90055ac807f71a3e7833843ed665d62a0a68 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 19 Jul 2026 23:02:04 +0100 Subject: [PATCH 06/47] Recipe object literal fixed so it can prints the ingredients on new lines. --- Sprint-2/debug/recipe.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index 6cbdd22cd..f4ae9ed86 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -11,5 +11,11 @@ const recipe = { }; console.log(`${recipe.title} serves ${recipe.serves} - ingredients: -${recipe}`); +ingredients: +${recipe.ingredients[0]} +${recipe.ingredients[1]} +${recipe.ingredients[2]} +${recipe.ingredients[3]} +${recipe.ingredients[4]}`); + +// On line 15 we can add recipe.ingredients[] From 702b5badd16ab48282db08a03c1a2d5d9fd5959f Mon Sep 17 00:00:00 2001 From: russom Date: Thu, 23 Jul 2026 23:42:39 +0100 Subject: [PATCH 07/47] A fifth element removed from ingredients array which was unneeded --- Sprint-2/debug/recipe.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index f4ae9ed86..c84f86c58 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -15,7 +15,6 @@ ingredients: ${recipe.ingredients[0]} ${recipe.ingredients[1]} ${recipe.ingredients[2]} -${recipe.ingredients[3]} -${recipe.ingredients[4]}`); +${recipe.ingredients[3]}`); // On line 15 we can add recipe.ingredients[] From 583bb2cfbab224c86525c4d5c99d592df44f0efe Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 13:08:01 +0100 Subject: [PATCH 08/47] Tests created for all cases. --- Sprint-2/implement/contains.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 326bdb1f2..8303cc021 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -16,20 +16,37 @@ 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 an object with property returns true", function () { + expect(contains({ a: 1, b: 2 }, "a")).toBe(true); +}); +test("contains on an object without property returns false", function () { + expect(contains({ a: 1, b: 2 }, "d")).toBe(false); +}); // 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", function () { + expect(contains({}, "a")).toBe(false); +}); // Given an object with properties // When passed to contains with an existing property name // Then it should return true +test("contain on object with properties", function () { + expect(contains({ c: 4, d: 5 }, "c")).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 object with non-existent property name returns false", function () { + expect(contains({ c: 4, d: 5 }, "x")).toBe(false); +}); // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error +test("contain on invalid parameters returns false", function () { + expect(contains([], "0")).toBe(false); +}); From c0f9787ba7c06be1ab16dcc0d25bbbf16190611e Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 13:08:49 +0100 Subject: [PATCH 09/47] function implemented for checking property exist in an object. --- Sprint-2/implement/contains.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index cd779308a..d2b26ee30 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,3 +1,10 @@ -function contains() {} +function contains(object, property) { + for (let key in object) { + if (key === property) { + return true; + } + } + return false; +} module.exports = contains; From 552c68c03668bea472f050f3104846c620c7d63f Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 13:53:50 +0100 Subject: [PATCH 10/47] Initial test case created --- Sprint-2/implement/lookup.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index 547e06c5a..179be88fe 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,6 +1,12 @@ const createLookup = require("./lookup.js"); -test.todo("creates a country currency code lookup for multiple codes"); +test.todo("creates a country currency code lookup for multiple codes", function() { + const countryCurrency = [ + ["US", "USD"], + ["CA", "CAD"], + ]; + expect(createLookup(countryCurrency)).toEqual({"US": "USD", "CAN": "CAD"}) +}); /* From 9058a376f5a17478b79816b3e38333af1cb5303f Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 13:54:30 +0100 Subject: [PATCH 11/47] Function implemented for creating an abject from key-value array. --- Sprint-2/implement/lookup.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index a6746e07f..a606d30f0 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -1,5 +1,8 @@ -function createLookup() { - // implementation here +function createLookup(pairs) { + let obj = {}; + for (let pair of pairs) { + obj[pair[0]] = pair[1] + } } module.exports = createLookup; From ce06e182f5c72bf04d9f84d31a1931ed2ec91f22 Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 14:08:23 +0100 Subject: [PATCH 12/47] Spelling mistakes and bug in CA key fixed. Test passes. --- Sprint-2/implement/lookup.test.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index 179be88fe..d39768202 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,11 +1,16 @@ const createLookup = require("./lookup.js"); -test.todo("creates a country currency code lookup for multiple codes", function() { - const countryCurrency = [ +test("creates a country currency code lookup for multiple codes", function() { + /*const countryCurrency = [ ["US", "USD"], ["CA", "CAD"], - ]; - expect(createLookup(countryCurrency)).toEqual({"US": "USD", "CAN": "CAD"}) + ];*/ + expect( + createLookup([ + ["US", "USD"], + ["CA", "CAD"], + ]) + ).toEqual({US: "USD", CA: "CAD",}); }); /* From e6267acfe756d4e0186034bf93ec657875c564af Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 14:08:51 +0100 Subject: [PATCH 13/47] Missing return obj added. --- Sprint-2/implement/lookup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index a606d30f0..2ff7eb12c 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -3,6 +3,7 @@ function createLookup(pairs) { for (let pair of pairs) { obj[pair[0]] = pair[1] } + return obj; } module.exports = createLookup; From 14c848cae7c98de1646ebf8612ec63a9900b4612 Mon Sep 17 00:00:00 2001 From: russom Date: Fri, 24 Jul 2026 14:09:53 +0100 Subject: [PATCH 14/47] Commented unneeded code deleted. --- .gitignore | 1 + Sprint-2/implement/lookup.test.js | 4 ---- prep/example2.js | 10 ++++++++++ prep/meadian1.test.js | 7 +++++++ prep/meadian2.js | 22 ++++++++++++++++++++++ prep/mean1.js | 1 + prep/mean1.test.js | 10 ++++++++++ prep/median1.js | 0 prep/newarray.js | 7 +++++++ prep/query-string-test.js | 12 ++++++++++++ 10 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 prep/example2.js create mode 100644 prep/meadian1.test.js create mode 100644 prep/meadian2.js create mode 100644 prep/mean1.js create mode 100644 prep/mean1.test.js create mode 100644 prep/median1.js create mode 100644 prep/newarray.js create mode 100644 prep/query-string-test.js diff --git a/.gitignore b/.gitignore index 8ee70353f..6fca67473 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules **/.DS_Store .idea package-lock.json +prep/example.js diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index d39768202..5c1c46e29 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,10 +1,6 @@ const createLookup = require("./lookup.js"); test("creates a country currency code lookup for multiple codes", function() { - /*const countryCurrency = [ - ["US", "USD"], - ["CA", "CAD"], - ];*/ expect( createLookup([ ["US", "USD"], diff --git a/prep/example2.js b/prep/example2.js new file mode 100644 index 000000000..c91d5567c --- /dev/null +++ b/prep/example2.js @@ -0,0 +1,10 @@ +function swapFirstArrayLast(arr) { + let swapped = arr[0]; + arr[0] = arr[4]; + arr[4] = swapped; +} + +const myArray = [5, 2, 3, 4, 1]; +swapFirstArrayLast(myArray); +console.log(myArray); +// bracket nottation for setting an array with index diff --git a/prep/meadian1.test.js b/prep/meadian1.test.js new file mode 100644 index 000000000..dc5456112 --- /dev/null +++ b/prep/meadian1.test.js @@ -0,0 +1,7 @@ +test("calculates the median of a list of odd length", () => { + const list = [10, 20, 30, 50, 60]; + const currentOutput = calculateMedian(list); + const targetOutput = 30; + + expect(currentOutput).toEqual(targetOutput); +}); diff --git a/prep/meadian2.js b/prep/meadian2.js new file mode 100644 index 000000000..1161d9a6a --- /dev/null +++ b/prep/meadian2.js @@ -0,0 +1,22 @@ +function calculateMedian(list) { + const middleIndex = Math.floor(list.length / 2); + const median = list.splice(middleIndex, 1)[0]; + + return median; +} +const lists = [1, 2, 3]; +console.log(calculateMedian(lists)); + +/* 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); + + if (list.length % 2 === 0) { + return (list[middleIndex - 1] + list[middleIndex]) / 2; + } + return list[middleIndex]; + } +} */ \ No newline at end of file diff --git a/prep/mean1.js b/prep/mean1.js new file mode 100644 index 000000000..b8ced42b8 --- /dev/null +++ b/prep/mean1.js @@ -0,0 +1 @@ +//A mean function to created for the tests in mean.test.js file. \ No newline at end of file diff --git a/prep/mean1.test.js b/prep/mean1.test.js new file mode 100644 index 000000000..ab7e8557d --- /dev/null +++ b/prep/mean1.test.js @@ -0,0 +1,10 @@ +// Calculating a mean function to be created on mean.js +// test cases to be written on this file prior to creating the mean function. + +test("calculates the mean of a list of numbers", () => { + const list = [3, 50, 7]; + const currentOutput = calculateMean(list); + const targetOutput = 20; + + expect(currentOutput).toEqual(targetOutput); // 20 is (3 + 50 + 7) / 3 +}); \ No newline at end of file diff --git a/prep/median1.js b/prep/median1.js new file mode 100644 index 000000000..e69de29bb diff --git a/prep/newarray.js b/prep/newarray.js new file mode 100644 index 000000000..5bb06b1d2 --- /dev/null +++ b/prep/newarray.js @@ -0,0 +1,7 @@ +function createArray(number) { + const newArray = []; + for (let counter = 1; counter <= number; counter++) { + newArray.push(counter); + } + return newArray; +} diff --git a/prep/query-string-test.js b/prep/query-string-test.js new file mode 100644 index 000000000..0effbff2c --- /dev/null +++ b/prep/query-string-test.js @@ -0,0 +1,12 @@ +//https://example.com/widgets?colour=blue&sort=newest; + +// { colour: blue, sort: "newest"} + +describe("", () => { + test("it will return empty object when we call parseQueryString", () => { + const input = " "; + const currentOutput = parseQueryString(input); + const targetOutput = {}; + expect(currentOutput).toBe(targetOutput); + }); +}); From c66861dcbd3965f0215b1533d4c2b171fd211629 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 17:52:38 +0100 Subject: [PATCH 15/47] First test values containing = tested --- Sprint-2/implement/querystring.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index 328b8df61..3f3cb5e52 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -3,7 +3,7 @@ // Below are some test cases the implementation doesn't handle well. // Fix the implementation for these tests, and try to think of as many other edge cases as possible - write tests and fix those too. -const parseQueryString = require("./querystring.js") +const parseQueryString = require("./querystring.js"); test("should parse values containing '='", () => { expect(parseQueryString("equation=a=b-2")).toEqual({ @@ -17,7 +17,7 @@ test("should ignore empty key-value pairs", () => { key2: "value2", }); }); - +/* test("should accept empty string as key or as value", () => { expect(parseQueryString("=value")).toEqual({ "": "value" }); expect(parseQueryString("key")).toEqual({ key: "" }); @@ -46,3 +46,4 @@ test("should store values of a key in an array when the key has 2 or more values foo: "bar", }); }); +*/ From c4dec19a2fcbcaa62ea40f36574cf6967b5bff7e Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 17:53:19 +0100 Subject: [PATCH 16/47] the for loop for testing values containing = fixed --- Sprint-2/implement/querystring.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 45ec4e5f3..aac4ff264 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -6,8 +6,15 @@ function parseQueryString(queryString) { const keyValuePairs = queryString.split("&"); for (const pair of keyValuePairs) { - const [key, value] = pair.split("="); + const everything = pair.split("="); + const key = everything.shift(); + const value = everything.join("="); queryParams[key] = value; + + //console.log(key); + //console.log(values); + //const [key, value] = pair.split("="); + //queryParams[key] = values; } return queryParams; From d5c28aa2686825b607ea170085bccaabbdf36e7d Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 18:25:08 +0100 Subject: [PATCH 17/47] If !pair added for checking empty strings. --- Sprint-2/implement/querystring.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index aac4ff264..d32396756 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -6,15 +6,13 @@ function parseQueryString(queryString) { const keyValuePairs = queryString.split("&"); for (const pair of keyValuePairs) { + if (!pair) { + continue; + } const everything = pair.split("="); const key = everything.shift(); const value = everything.join("="); queryParams[key] = value; - - //console.log(key); - //console.log(values); - //const [key, value] = pair.split("="); - //queryParams[key] = values; } return queryParams; From b10058d0c0ae090a94b7b19934a7e09f44a4875e Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 20:22:35 +0100 Subject: [PATCH 18/47] decodeURLComponent function used to decode percent-encoded characters test --- Sprint-2/implement/querystring.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index d32396756..aa4aa33e0 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -7,11 +7,11 @@ function parseQueryString(queryString) { for (const pair of keyValuePairs) { if (!pair) { - continue; + continue; } const everything = pair.split("="); - const key = everything.shift(); - const value = everything.join("="); + const key = decodeURIComponent(everything.shift()); + const value = decodeURIComponent(everything.join("=")); queryParams[key] = value; } From 7fc4886e9d306ac8fd04f81a552a012d1f86238c Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 20:35:00 +0100 Subject: [PATCH 19/47] Using a regular expression .replace(/\+/g, " ") the + sign is removed from the key and value. --- Sprint-2/implement/querystring.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index aa4aa33e0..6cbbd6c95 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -10,8 +10,8 @@ function parseQueryString(queryString) { continue; } const everything = pair.split("="); - const key = decodeURIComponent(everything.shift()); - const value = decodeURIComponent(everything.join("=")); + const key = decodeURIComponent(everything.shift().replace(/\+/g, " ")); + const value = decodeURIComponent(everything.join("=").replace(/\+/g, " ")); queryParams[key] = value; } From 946461b6667137ac41e47fedac417e4b74b2521b Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 21:24:46 +0100 Subject: [PATCH 20/47] Last test commented out --- Sprint-2/implement/querystring.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index 3f3cb5e52..11e8df52b 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -17,7 +17,7 @@ test("should ignore empty key-value pairs", () => { key2: "value2", }); }); -/* + test("should accept empty string as key or as value", () => { expect(parseQueryString("=value")).toEqual({ "": "value" }); expect(parseQueryString("key")).toEqual({ key: "" }); @@ -40,10 +40,11 @@ test("should replace '+' by ' '", () => { // Stretch exercise: Handling query strings that contain identical keys // Delete this test if you are not working on this optional case +/* test("should store values of a key in an array when the key has 2 or more values", () => { expect(parseQueryString("key=value1&key=value2&key=value3&foo=bar")).toEqual({ key: ["value1", "value2", "value3"], foo: "bar", }); }); -*/ +*/ \ No newline at end of file From 37e70cba3c08631752f44c0339bfd6b9a25f0cea Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 21:37:45 +0100 Subject: [PATCH 21/47] Test created for all the cases --- Sprint-2/implement/tally.test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 2ceffa8dd..74c370c9c 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -19,16 +19,27 @@ const tally = require("./tally.js"); // Given a function called tally // When passed an array of items // Then it should return an object containing the count for each unique item +test("tally on an array returns an object with item", function() { + expect(tally(["a"])).etEqual({a: 1}) +}) // Given an empty array // When passed to tally // Then it should return an empty object -test.todo("tally on an empty array returns an empty object"); +test("tally on an empty array returns an empty object", function() { + expect(tally([])).toEqual({}) +}); // Given an array with duplicate items // When passed to tally // Then it should return counts for each unique item +test("tally on duplicate items returns count of items", function() { + expect(tally(["a", "a", "a"])).toEqual({a: 3}) +}) // Given an invalid input like a string // When passed to tally // Then it should throw an error +test("tally on invalid input throws an error", function() { + expect(tally("string")).toBe("error") +}) \ No newline at end of file From 1b4063ad58f69f0766e0ca5b6da8c4e2ba5c0beb Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 21:56:23 +0100 Subject: [PATCH 22/47] function implemented for checking duplicate items. --- Sprint-2/implement/tally.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/tally.js b/Sprint-2/implement/tally.js index f47321812..8041a9c59 100644 --- a/Sprint-2/implement/tally.js +++ b/Sprint-2/implement/tally.js @@ -1,3 +1,9 @@ -function tally() {} +function tally(arr) { + const count = {}; + for (const item of arr) { + count[item] = (count[item] || 0) + 1; + } + return count; +} module.exports = tally; From af59161ff60edf0390712c200536597c11b11723 Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 22:15:56 +0100 Subject: [PATCH 23/47] for the last test for invalid input test adjusted so jest can check first and catch the error. --- Sprint-2/implement/tally.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 74c370c9c..c5a0029fd 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -20,7 +20,7 @@ const tally = require("./tally.js"); // When passed an array of items // Then it should return an object containing the count for each unique item test("tally on an array returns an object with item", function() { - expect(tally(["a"])).etEqual({a: 1}) + expect(tally(["a"])).toEqual({a: 1}) }) // Given an empty array @@ -41,5 +41,5 @@ test("tally on duplicate items returns count of items", function() { // When passed to tally // Then it should throw an error test("tally on invalid input throws an error", function() { - expect(tally("string")).toBe("error") + expect(() => tally("string")).toThrow("Invalid input") }) \ No newline at end of file From 0877d2d13438f5de7eec2f74fda410315bfe330e Mon Sep 17 00:00:00 2001 From: russom Date: Sat, 25 Jul 2026 22:17:27 +0100 Subject: [PATCH 24/47] if statement added to check the item is number not string. --- Sprint-2/implement/tally.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-2/implement/tally.js b/Sprint-2/implement/tally.js index 8041a9c59..04969f933 100644 --- a/Sprint-2/implement/tally.js +++ b/Sprint-2/implement/tally.js @@ -1,4 +1,7 @@ function tally(arr) { + if (!Array.isArray(arr)) { + throw new Error("Invalid input"); + } const count = {}; for (const item of arr) { count[item] = (count[item] || 0) + 1; From ab84c24b7ac76215d383272c1e4c6db85404891b Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 26 Jul 2026 15:19:57 +0100 Subject: [PATCH 25/47] the tittle element changed into Quote generator app" --- Sprint-3/quote-generator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..9c0026131 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,7 +3,7 @@ - Title here + Quote generator app" From 57bcdde48cc2b90f49655a92fa31052ededae270 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 26 Jul 2026 22:53:51 +0100 Subject: [PATCH 26/47] showRandomQuote function implemented to display randomised quote upon page refresh or 'new quote' button click --- package.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 000000000..1d797bd76 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "jest": "^30.4.2" + } +} From 6100dc967189147f0bc1f881f15998420430f9d8 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 26 Jul 2026 22:56:07 +0100 Subject: [PATCH 27/47] showRandomQuote function implemented to display randomised quote upon page refresh or 'new quote' button click --- Sprint-3/quote-generator/quotes.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..42c6b1e28 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -16,6 +16,7 @@ // pickFromArray(['a','b','c','d']) // maybe returns 'c' // You don't need to change this function + function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } @@ -490,4 +491,27 @@ const quotes = [ }, ]; +console.log(pickFromArray(quotes)); // call pickFromArray with the quotes array to check you get a random quote + +//When the page loads it should show a random quote from the `quotes` array on the screen. It should also show who said the quote. + +//When you click a button on the screen it should change the quote on the screen. + +const button = document.querySelector("#new-quote"); +const quoteText = document.querySelector("#quote"); +const quoteAuthor = document.querySelector("#author"); + +function showRandomQuote() { + const randomQuote = pickFromArray(quotes); + quoteText.textContent = randomQuote.quote; + quoteAuthor.textContent = randomQuote.author; +} + +showRandomQuote(); + +button.addEventListener("click", showRandomQuote); + +//function pickFromArray(choices) { +// return choices[Math.floor(Math.random() * choices.length)]; +//} \ No newline at end of file From 1ca1d5e3aecba7dff92f81ebb22f978b3cf87bde Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 26 Jul 2026 22:56:42 +0100 Subject: [PATCH 28/47] hello there changed to welcome on h1 element --- Sprint-3/quote-generator/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 9c0026131..e1b96f50c 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -5,9 +5,10 @@ Quote generator app" + -

hello there

+

Welcome

From 1547e5bb12a61d021661a17b17c2d1dac405baf0 Mon Sep 17 00:00:00 2001 From: russom Date: Sun, 26 Jul 2026 22:57:11 +0100 Subject: [PATCH 29/47] Simple changes made to the styling --- Sprint-3/quote-generator/style.css | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 63cedf2d2..6c92827a5 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1 +1,28 @@ /** Write your CSS in here **/ + +body { + color: rgb(48, 46, 46); + background-color: rgb(238, 235, 235); + font-family: Arial, sans-serif; + margin: 0; + padding: 20px; +} + +h1 { + text-align: center; + font-size: 2.5rem; + color: ; +} + +p { + font-size: 1rem; + color: ; +} + +button { + background-color: rgb(221, 235, 116); + color: rgb(131, 95, 29); + border: none; + padding: 10px; + border-radius: 5px; +} From e72732eeca640bd0e4fc0b74936c1f0fb3db83c1 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 29 Jul 2026 21:23:45 +0100 Subject: [PATCH 30/47] "Delete completed tasks" button added. --- Sprint-3/todo-list/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 4d12c4654..5cc97646f 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -16,6 +16,8 @@

My ToDo List

+ +
    From f997781fa90dc81c96dbddf7094ef3a54078a58f Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 29 Jul 2026 21:24:50 +0100 Subject: [PATCH 31/47] Delete completed function started being implemented --- Sprint-3/todo-list/todos.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-3/todo-list/todos.mjs b/Sprint-3/todo-list/todos.mjs index f17ab6a25..e05d65fcc 100644 --- a/Sprint-3/todo-list/todos.mjs +++ b/Sprint-3/todo-list/todos.mjs @@ -26,4 +26,13 @@ export function toggleCompletedOnTask(todos, taskIndex) { if (todos[taskIndex]) { todos[taskIndex].completed = !todos[taskIndex].completed; } +} + +// To remove all completed ToDos from the given list. +export function deleteCompleted(todoList) { + if (todoList) { + toggleCompletedOnTask(todoList); + } + + } \ No newline at end of file From d674f5c5c5f08f5fea3dc50b00dfcc6cf0d931da Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 29 Jul 2026 21:37:11 +0100 Subject: [PATCH 32/47] comment added --- Sprint-3/todo-list/index.html | 2 +- Sprint-3/todo-list/todos.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 5cc97646f..317e589cc 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -16,7 +16,7 @@

    My ToDo List

    - +
    diff --git a/Sprint-3/todo-list/todos.mjs b/Sprint-3/todo-list/todos.mjs index e05d65fcc..c7895a891 100644 --- a/Sprint-3/todo-list/todos.mjs +++ b/Sprint-3/todo-list/todos.mjs @@ -28,7 +28,7 @@ export function toggleCompletedOnTask(todos, taskIndex) { } } -// To remove all completed ToDos from the given list. +// Remove all completed ToDos if they exists and are toggled. export function deleteCompleted(todoList) { if (todoList) { toggleCompletedOnTask(todoList); From 81f78634978c259c204ac6667758cb11adf99067 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 3 Aug 2026 22:56:41 +0100 Subject: [PATCH 33/47] Title element updated to 'Alarm clock app' --- Sprint-3/alarmclock/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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
    From 27fa3e99c3b579825ac63f69d006c19f22447e69 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 3 Aug 2026 23:42:06 +0100 Subject: [PATCH 34/47] Time and heading variables declared. --- Sprint-3/alarmclock/alarmclock.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..83db4e416 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,8 @@ -function setAlarm() {} +function setAlarm() { + let time = document.getElementById("alarmSet"); + let heading = document.getElementById("timeRemaining"); + +} // DO NOT EDIT BELOW HERE From e0849c04b707b0c57e0905d7d0647b56e6e516ea Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 20:53:26 +0100 Subject: [PATCH 35/47] Minutes and seconds declared. heading.innerText changed to include remaining minutes and seconds. --- Sprint-3/alarmclock/alarmclock.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 83db4e416..d2585521c 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,7 +1,15 @@ function setAlarm() { + let time = document.getElementById("alarmSet"); + let heading = document.getElementById("timeRemaining"); - + + let minutes = Math.floor(time / 60); + let seconds = time % 60; + + heading.innerText = "Time Remaining: " + + String(minutes).padStart(2, "0") + ":" + + String(seconds.padStart(2, "0")); } // DO NOT EDIT BELOW HERE From e16e1b0c0d52bebed79b5f69fa16a79c2b391980 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 21:31:01 +0100 Subject: [PATCH 36/47] setIntervals timer started. Minutes and seconds recalculated again. --- Sprint-3/alarmclock/alarmclock.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index d2585521c..3016b79c4 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -10,6 +10,18 @@ function setAlarm() { heading.innerText = "Time Remaining: " + String(minutes).padStart(2, "0") + ":" + String(seconds.padStart(2, "0")); + + let timer = setIntervals(function () { + time = time -1; + + let minutes = Math.floor(time / 60); + let seconds = time % 60; + + heading.innerText = "Time Remaining: " + + String(minutes).padStart(2, "0") + ":" + + String(seconds.padStart(2, "0")); + + } } // DO NOT EDIT BELOW HERE From 6e2d741b2379835b57380251e217106f3810c287 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 21:38:48 +0100 Subject: [PATCH 37/47] if condition for checking count down is zero. Then paly the alarm and reset the timer. --- Sprint-3/alarmclock/alarmclock.js | 35 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 3016b79c4..b8573a44e 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,27 +1,34 @@ function setAlarm() { - let time = document.getElementById("alarmSet"); - + let heading = document.getElementById("timeRemaining"); - + let minutes = Math.floor(time / 60); let seconds = time % 60; - - heading.innerText = "Time Remaining: " + - String(minutes).padStart(2, "0") + ":" + - String(seconds.padStart(2, "0")); + + heading.innerText = + "Time Remaining: " + + String(minutes).padStart(2, "0") + + ":" + + String(seconds.padStart(2, "0")); let timer = setIntervals(function () { - time = time -1; - + time = time - 1; + let minutes = Math.floor(time / 60); let seconds = time % 60; - heading.innerText = "Time Remaining: " + - String(minutes).padStart(2, "0") + ":" + - String(seconds.padStart(2, "0")); - - } + heading.innerText = + "Time Remaining: " + + String(minutes).padStart(2, "0") + + ":" + + String(seconds.padStart(2, "0")); + + if (time === 0) { + playAlarm(); + clearInterval(timer); + } + }, 1000); } // DO NOT EDIT BELOW HERE From b7754d4a6c9b3dd1adf3c4724f84fd9d504e9c74 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 21:47:24 +0100 Subject: [PATCH 38/47] Errors fixed --- Sprint-3/alarmclock/alarmclock.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index b8573a44e..5c68a2e5e 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,5 +1,5 @@ function setAlarm() { - let time = document.getElementById("alarmSet"); + let time = (Number.document.getElementById("alarmSet").value); let heading = document.getElementById("timeRemaining"); @@ -10,7 +10,7 @@ function setAlarm() { "Time Remaining: " + String(minutes).padStart(2, "0") + ":" + - String(seconds.padStart(2, "0")); + String(seconds).padStart(2, "0"); let timer = setIntervals(function () { time = time - 1; From 7ea21cfe030772d4e5d8ab4b7245441afaadba03 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 21:55:03 +0100 Subject: [PATCH 39/47] Typos and errors in the code corrected. --- Sprint-3/alarmclock/alarmclock.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 5c68a2e5e..edb5679cc 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,5 +1,5 @@ function setAlarm() { - let time = (Number.document.getElementById("alarmSet").value); + let time = Number(document.getElementById("alarmSet").value); let heading = document.getElementById("timeRemaining"); @@ -12,7 +12,7 @@ function setAlarm() { ":" + String(seconds).padStart(2, "0"); - let timer = setIntervals(function () { + let timer = setInterval(function () { time = time - 1; let minutes = Math.floor(time / 60); @@ -22,7 +22,7 @@ function setAlarm() { "Time Remaining: " + String(minutes).padStart(2, "0") + ":" + - String(seconds.padStart(2, "0")); + String(seconds).padStart(2, "0"); if (time === 0) { playAlarm(); From a9865b0b0cb3b0acc5128fbf8a914df250412e2c Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:21:09 +0100 Subject: [PATCH 40/47] Restore files accidentally removed from branch --- .gitignore | 1 - Sprint-1/fix/median.js | 15 +++----------- Sprint-2/debug/address.js | 2 +- Sprint-2/debug/author.js | 7 ++----- Sprint-2/debug/recipe.js | 9 ++------- Sprint-2/implement/contains.js | 9 +-------- Sprint-2/implement/contains.test.js | 19 +----------------- Sprint-2/implement/lookup.js | 8 ++------ Sprint-2/implement/lookup.test.js | 9 +-------- Sprint-2/implement/querystring.js | 7 +------ Sprint-2/implement/querystring.test.js | 4 +--- Sprint-2/implement/tally.js | 11 +---------- Sprint-2/implement/tally.test.js | 13 +------------ Sprint-3/quote-generator/index.html | 5 ++--- Sprint-3/quote-generator/quotes.js | 24 ----------------------- Sprint-3/quote-generator/style.css | 27 -------------------------- Sprint-3/todo-list/index.html | 2 -- Sprint-3/todo-list/todos.mjs | 9 --------- 18 files changed, 19 insertions(+), 162 deletions(-) diff --git a/.gitignore b/.gitignore index 6fca67473..8ee70353f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ node_modules **/.DS_Store .idea package-lock.json -prep/example.js diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index 561e70090..b22590bc6 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,18 +6,9 @@ // 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) - } - 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; } module.exports = calculateMedian; diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 36d2f865d..940a6af83 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -12,4 +12,4 @@ const address = { postcode: "XYZ 123", }; -console.log(`My house number is ${address.houseNumber}`); +console.log(`My house number is ${address[0]}`); diff --git a/Sprint-2/debug/author.js b/Sprint-2/debug/author.js index 419780a78..8c2125977 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -11,9 +11,6 @@ const author = { alive: true, }; -for (const value in author) { - console.log(author[value]); +for (const value of author) { + console.log(value); } - -// The for of loop is trying to iterate through the object like an array. -// For in loop would work better. \ No newline at end of file diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index c84f86c58..6cbdd22cd 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -11,10 +11,5 @@ const recipe = { }; console.log(`${recipe.title} serves ${recipe.serves} -ingredients: -${recipe.ingredients[0]} -${recipe.ingredients[1]} -${recipe.ingredients[2]} -${recipe.ingredients[3]}`); - -// On line 15 we can add recipe.ingredients[] + ingredients: +${recipe}`); diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index d2b26ee30..cd779308a 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,10 +1,3 @@ -function contains(object, property) { - for (let key in object) { - if (key === property) { - return true; - } - } - return false; -} +function contains() {} module.exports = contains; diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 8303cc021..326bdb1f2 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -16,37 +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 an object with property returns true", function () { - expect(contains({ a: 1, b: 2 }, "a")).toBe(true); -}); -test("contains on an object without property returns false", function () { - expect(contains({ a: 1, b: 2 }, "d")).toBe(false); -}); // Given an empty object // When passed to contains // Then it should return false -test("contains on empty object returns false", function () { - expect(contains({}, "a")).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("contain on object with properties", function () { - expect(contains({ c: 4, d: 5 }, "c")).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 object with non-existent property name returns false", function () { - expect(contains({ c: 4, d: 5 }, "x")).toBe(false); -}); // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error -test("contain on invalid parameters returns false", function () { - expect(contains([], "0")).toBe(false); -}); diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index 2ff7eb12c..a6746e07f 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -1,9 +1,5 @@ -function createLookup(pairs) { - let obj = {}; - for (let pair of pairs) { - obj[pair[0]] = pair[1] - } - return obj; +function createLookup() { + // implementation here } module.exports = createLookup; diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index 5c1c46e29..547e06c5a 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,13 +1,6 @@ const createLookup = require("./lookup.js"); -test("creates a country currency code lookup for multiple codes", function() { - expect( - createLookup([ - ["US", "USD"], - ["CA", "CAD"], - ]) - ).toEqual({US: "USD", CA: "CAD",}); -}); +test.todo("creates a country currency code lookup for multiple codes"); /* diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 6cbbd6c95..45ec4e5f3 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -6,12 +6,7 @@ function parseQueryString(queryString) { const keyValuePairs = queryString.split("&"); for (const pair of keyValuePairs) { - if (!pair) { - continue; - } - const everything = pair.split("="); - const key = decodeURIComponent(everything.shift().replace(/\+/g, " ")); - const value = decodeURIComponent(everything.join("=").replace(/\+/g, " ")); + const [key, value] = pair.split("="); queryParams[key] = value; } diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index 11e8df52b..328b8df61 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -3,7 +3,7 @@ // Below are some test cases the implementation doesn't handle well. // Fix the implementation for these tests, and try to think of as many other edge cases as possible - write tests and fix those too. -const parseQueryString = require("./querystring.js"); +const parseQueryString = require("./querystring.js") test("should parse values containing '='", () => { expect(parseQueryString("equation=a=b-2")).toEqual({ @@ -40,11 +40,9 @@ test("should replace '+' by ' '", () => { // Stretch exercise: Handling query strings that contain identical keys // Delete this test if you are not working on this optional case -/* test("should store values of a key in an array when the key has 2 or more values", () => { expect(parseQueryString("key=value1&key=value2&key=value3&foo=bar")).toEqual({ key: ["value1", "value2", "value3"], foo: "bar", }); }); -*/ \ No newline at end of file diff --git a/Sprint-2/implement/tally.js b/Sprint-2/implement/tally.js index 04969f933..f47321812 100644 --- a/Sprint-2/implement/tally.js +++ b/Sprint-2/implement/tally.js @@ -1,12 +1,3 @@ -function tally(arr) { - if (!Array.isArray(arr)) { - throw new Error("Invalid input"); - } - const count = {}; - for (const item of arr) { - count[item] = (count[item] || 0) + 1; - } - return count; -} +function tally() {} module.exports = tally; diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index c5a0029fd..2ceffa8dd 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -19,27 +19,16 @@ const tally = require("./tally.js"); // Given a function called tally // When passed an array of items // Then it should return an object containing the count for each unique item -test("tally on an array returns an object with item", function() { - expect(tally(["a"])).toEqual({a: 1}) -}) // Given an empty array // When passed to tally // Then it should return an empty object -test("tally on an empty array returns an empty object", function() { - expect(tally([])).toEqual({}) -}); +test.todo("tally on an empty array returns an empty object"); // Given an array with duplicate items // When passed to tally // Then it should return counts for each unique item -test("tally on duplicate items returns count of items", function() { - expect(tally(["a", "a", "a"])).toEqual({a: 3}) -}) // Given an invalid input like a string // When passed to tally // Then it should throw an error -test("tally on invalid input throws an error", function() { - expect(() => tally("string")).toThrow("Invalid input") -}) \ No newline at end of file diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index e1b96f50c..30b434bcf 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,12 +3,11 @@ - Quote generator app" + Title here - -

    Welcome

    +

    hello there

    diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 42c6b1e28..4a4d04b72 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -16,7 +16,6 @@ // pickFromArray(['a','b','c','d']) // maybe returns 'c' // You don't need to change this function - function pickFromArray(choices) { return choices[Math.floor(Math.random() * choices.length)]; } @@ -491,27 +490,4 @@ const quotes = [ }, ]; -console.log(pickFromArray(quotes)); // call pickFromArray with the quotes array to check you get a random quote - -//When the page loads it should show a random quote from the `quotes` array on the screen. It should also show who said the quote. - -//When you click a button on the screen it should change the quote on the screen. - -const button = document.querySelector("#new-quote"); -const quoteText = document.querySelector("#quote"); -const quoteAuthor = document.querySelector("#author"); - -function showRandomQuote() { - const randomQuote = pickFromArray(quotes); - quoteText.textContent = randomQuote.quote; - quoteAuthor.textContent = randomQuote.author; -} - -showRandomQuote(); - -button.addEventListener("click", showRandomQuote); - -//function pickFromArray(choices) { -// return choices[Math.floor(Math.random() * choices.length)]; -//} \ No newline at end of file diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 6c92827a5..63cedf2d2 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1,28 +1 @@ /** Write your CSS in here **/ - -body { - color: rgb(48, 46, 46); - background-color: rgb(238, 235, 235); - font-family: Arial, sans-serif; - margin: 0; - padding: 20px; -} - -h1 { - text-align: center; - font-size: 2.5rem; - color: ; -} - -p { - font-size: 1rem; - color: ; -} - -button { - background-color: rgb(221, 235, 116); - color: rgb(131, 95, 29); - border: none; - padding: 10px; - border-radius: 5px; -} diff --git a/Sprint-3/todo-list/index.html b/Sprint-3/todo-list/index.html index 317e589cc..4d12c4654 100644 --- a/Sprint-3/todo-list/index.html +++ b/Sprint-3/todo-list/index.html @@ -16,8 +16,6 @@

    My ToDo List

    - -
      diff --git a/Sprint-3/todo-list/todos.mjs b/Sprint-3/todo-list/todos.mjs index c7895a891..f17ab6a25 100644 --- a/Sprint-3/todo-list/todos.mjs +++ b/Sprint-3/todo-list/todos.mjs @@ -26,13 +26,4 @@ export function toggleCompletedOnTask(todos, taskIndex) { if (todos[taskIndex]) { todos[taskIndex].completed = !todos[taskIndex].completed; } -} - -// Remove all completed ToDos if they exists and are toggled. -export function deleteCompleted(todoList) { - if (todoList) { - toggleCompletedOnTask(todoList); - } - - } \ No newline at end of file From 43fcdea8de8bc6d5b5792e0988d226ed5d484820 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:28:22 +0100 Subject: [PATCH 41/47] Remove files that don't belong in this PR --- prep/example2.js | 10 ---------- prep/meadian1.test.js | 7 ------- prep/meadian2.js | 22 ---------------------- prep/mean1.js | 1 - prep/mean1.test.js | 10 ---------- prep/median1.js | 0 prep/newarray.js | 7 ------- prep/query-string-test.js | 12 ------------ 8 files changed, 69 deletions(-) delete mode 100644 prep/example2.js delete mode 100644 prep/meadian1.test.js delete mode 100644 prep/meadian2.js delete mode 100644 prep/mean1.js delete mode 100644 prep/mean1.test.js delete mode 100644 prep/median1.js delete mode 100644 prep/newarray.js delete mode 100644 prep/query-string-test.js diff --git a/prep/example2.js b/prep/example2.js deleted file mode 100644 index c91d5567c..000000000 --- a/prep/example2.js +++ /dev/null @@ -1,10 +0,0 @@ -function swapFirstArrayLast(arr) { - let swapped = arr[0]; - arr[0] = arr[4]; - arr[4] = swapped; -} - -const myArray = [5, 2, 3, 4, 1]; -swapFirstArrayLast(myArray); -console.log(myArray); -// bracket nottation for setting an array with index diff --git a/prep/meadian1.test.js b/prep/meadian1.test.js deleted file mode 100644 index dc5456112..000000000 --- a/prep/meadian1.test.js +++ /dev/null @@ -1,7 +0,0 @@ -test("calculates the median of a list of odd length", () => { - const list = [10, 20, 30, 50, 60]; - const currentOutput = calculateMedian(list); - const targetOutput = 30; - - expect(currentOutput).toEqual(targetOutput); -}); diff --git a/prep/meadian2.js b/prep/meadian2.js deleted file mode 100644 index 1161d9a6a..000000000 --- a/prep/meadian2.js +++ /dev/null @@ -1,22 +0,0 @@ -function calculateMedian(list) { - const middleIndex = Math.floor(list.length / 2); - const median = list.splice(middleIndex, 1)[0]; - - return median; -} -const lists = [1, 2, 3]; -console.log(calculateMedian(lists)); - -/* 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); - - if (list.length % 2 === 0) { - return (list[middleIndex - 1] + list[middleIndex]) / 2; - } - return list[middleIndex]; - } -} */ \ No newline at end of file diff --git a/prep/mean1.js b/prep/mean1.js deleted file mode 100644 index b8ced42b8..000000000 --- a/prep/mean1.js +++ /dev/null @@ -1 +0,0 @@ -//A mean function to created for the tests in mean.test.js file. \ No newline at end of file diff --git a/prep/mean1.test.js b/prep/mean1.test.js deleted file mode 100644 index ab7e8557d..000000000 --- a/prep/mean1.test.js +++ /dev/null @@ -1,10 +0,0 @@ -// Calculating a mean function to be created on mean.js -// test cases to be written on this file prior to creating the mean function. - -test("calculates the mean of a list of numbers", () => { - const list = [3, 50, 7]; - const currentOutput = calculateMean(list); - const targetOutput = 20; - - expect(currentOutput).toEqual(targetOutput); // 20 is (3 + 50 + 7) / 3 -}); \ No newline at end of file diff --git a/prep/median1.js b/prep/median1.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/prep/newarray.js b/prep/newarray.js deleted file mode 100644 index 5bb06b1d2..000000000 --- a/prep/newarray.js +++ /dev/null @@ -1,7 +0,0 @@ -function createArray(number) { - const newArray = []; - for (let counter = 1; counter <= number; counter++) { - newArray.push(counter); - } - return newArray; -} diff --git a/prep/query-string-test.js b/prep/query-string-test.js deleted file mode 100644 index 0effbff2c..000000000 --- a/prep/query-string-test.js +++ /dev/null @@ -1,12 +0,0 @@ -//https://example.com/widgets?colour=blue&sort=newest; - -// { colour: blue, sort: "newest"} - -describe("", () => { - test("it will return empty object when we call parseQueryString", () => { - const input = " "; - const currentOutput = parseQueryString(input); - const targetOutput = {}; - expect(currentOutput).toBe(targetOutput); - }); -}); From 24e00dcaf76755b68ae8880cf3c75d8943ecb0a1 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:35:05 +0100 Subject: [PATCH 42/47] Remove package.json from tracking, keep locally --- Sprint-3/alarmclock/package.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Sprint-3/alarmclock/package.json diff --git a/Sprint-3/alarmclock/package.json b/Sprint-3/alarmclock/package.json deleted file mode 100644 index e1331e071..000000000 --- a/Sprint-3/alarmclock/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "alarmclock", - "version": "1.0.0", - "license": "CC-BY-SA-4.0", - "description": "You must update this package", - "scripts": { - "test": "jest --config=../jest.config.js alarmclock" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/CodeYourFuture/CYF-Coursework-Template.git" - }, - "bugs": { - "url": "https://github.com/CodeYourFuture/CYF-Coursework-Template/issues" - }, - "homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme" -} From f3c7417fba164e6f7c371ab7098aaec9dcc23a9b Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:35:50 +0100 Subject: [PATCH 43/47] Ignore local package.json --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8ee70353f..4cf08f517 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules **/.DS_Store .idea package-lock.json +Sprint-3/alarmclock/package.json From 3cddd7d16d7071b2d60336c78e290ac772ef01aa Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:38:20 +0100 Subject: [PATCH 44/47] Remove unnecessary root package.json --- .gitignore | 2 ++ package.json | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 package.json diff --git a/.gitignore b/.gitignore index 4cf08f517..852a7b7d9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ node_modules .idea package-lock.json Sprint-3/alarmclock/package.json +package.json +/package.json diff --git a/package.json b/package.json deleted file mode 100644 index 1d797bd76..000000000 --- a/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "jest": "^30.4.2" - } -} From 0497772304b1e92cf430c9860757fe1697e5ef21 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:39:43 +0100 Subject: [PATCH 45/47] Revert .gitignore change --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 852a7b7d9..8ee70353f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,3 @@ node_modules **/.DS_Store .idea package-lock.json -Sprint-3/alarmclock/package.json -package.json -/package.json From c1f876ab1b3f3784c11931fbe768732cb863a181 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 22:41:11 +0100 Subject: [PATCH 46/47] Restore package.json to match main --- Sprint-3/alarmclock/package.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Sprint-3/alarmclock/package.json diff --git a/Sprint-3/alarmclock/package.json b/Sprint-3/alarmclock/package.json new file mode 100644 index 000000000..e1331e071 --- /dev/null +++ b/Sprint-3/alarmclock/package.json @@ -0,0 +1,17 @@ +{ + "name": "alarmclock", + "version": "1.0.0", + "license": "CC-BY-SA-4.0", + "description": "You must update this package", + "scripts": { + "test": "jest --config=../jest.config.js alarmclock" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/CodeYourFuture/CYF-Coursework-Template.git" + }, + "bugs": { + "url": "https://github.com/CodeYourFuture/CYF-Coursework-Template/issues" + }, + "homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme" +} From 3dbc4adaed1611ad779c23198989282144524f00 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 4 Aug 2026 23:00:34 +0100 Subject: [PATCH 47/47] Minor formatting touch --- Sprint-3/alarmclock/alarmclock.test.js | 1 + Sprint-3/alarmclock/package.json | 1 + Sprint-3/alarmclock/readme.md | 1 + Sprint-3/alarmclock/style.css | 1 + 4 files changed, 4 insertions(+) diff --git a/Sprint-3/alarmclock/alarmclock.test.js b/Sprint-3/alarmclock/alarmclock.test.js index 85b7356dc..1122134db 100644 --- a/Sprint-3/alarmclock/alarmclock.test.js +++ b/Sprint-3/alarmclock/alarmclock.test.js @@ -102,3 +102,4 @@ test("should play audio when the timer reaches zero", () => { expect(mockPlayAlarm).toHaveBeenCalledTimes(1); }); + diff --git a/Sprint-3/alarmclock/package.json b/Sprint-3/alarmclock/package.json index e1331e071..703c0bdf9 100644 --- a/Sprint-3/alarmclock/package.json +++ b/Sprint-3/alarmclock/package.json @@ -15,3 +15,4 @@ }, "homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme" } + diff --git a/Sprint-3/alarmclock/readme.md b/Sprint-3/alarmclock/readme.md index c00a20c9c..fe39230c2 100644 --- a/Sprint-3/alarmclock/readme.md +++ b/Sprint-3/alarmclock/readme.md @@ -30,3 +30,4 @@ If you have time and want to do more why not try - Make the background change color when the alarm clock finishes - Try making the background flash! - Could you add `pause` functionality so that the count down stops and then you restart it later? + diff --git a/Sprint-3/alarmclock/style.css b/Sprint-3/alarmclock/style.css index 0c72de38b..feb82fffc 100644 --- a/Sprint-3/alarmclock/style.css +++ b/Sprint-3/alarmclock/style.css @@ -13,3 +13,4 @@ h1 { text-align: center; } +