From f55cbf8e4acef7627287ed1e2505bd784b46191b Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 14 Mar 2026 14:17:41 +0000 Subject: [PATCH 01/17] Changed the title to Alarm Clock App --- Sprint-3/alarmclock/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..18a51fc66 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,10 +1,10 @@ - + - Title here + Alarm Clock App
From 333486d8f4160f84b421ab52a63fadb426e7dca1 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 14 Mar 2026 14:18:59 +0000 Subject: [PATCH 02/17] Revert title to default in index.html --- 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 18a51fc66..f16f1bd6c 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -4,7 +4,7 @@ - Alarm Clock App + Title here
From 77a4262fcf7219de1144ca0717ee7d5f9036e595 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Mar 2026 10:17:59 +0000 Subject: [PATCH 03/17] fixed bug in address.js and added prediction/explanation to issue --- Sprint-2/debug/address.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 940a6af83..c1efefd24 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -1,5 +1,9 @@ // Predict and explain first... +// The console.log statement is attempting to use an index [0] but const address is structured as an object not an array. +// Since there is no property named 0 in the address object the console.log will return the string plus undefined. +// We must use key value pairs to get the value. To locate items from an object we can either use dot notation or bracket notation. + // This code should log out the houseNumber from the address object // but it isn't working... // Fix anything that isn't working @@ -12,4 +16,4 @@ const address = { postcode: "XYZ 123", }; -console.log(`My house number is ${address[0]}`); +console.log(`My house number is ${address.houseNumber}`); From 5f9fc25e505e272df7f03dd2c9d4256a70c6ab4c Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Mar 2026 10:32:48 +0000 Subject: [PATCH 04/17] updated author.js to include explanation of the bug and fixed the code. --- Sprint-2/debug/author.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-2/debug/author.js b/Sprint-2/debug/author.js index 8c2125977..74e1e2b23 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -3,6 +3,10 @@ // This program attempts to log out all the property values in the object. // But it isn't working. Explain why first and then fix the problem +// An object is not iterable by default it is a collection of keys and value pairs. This means their is no path for the for loop to follow. +// Due to this when we run this code we are going to get a type error. To fix this and log all the property values in the object; +// we must convert the object data into an array. + const author = { firstName: "Zadie", lastName: "Smith", @@ -11,6 +15,6 @@ const author = { alive: true, }; -for (const value of author) { +for (const value of Object.values(author)) { console.log(value); } From 6dbb61d7c902859a68000691b114f24d6f893493 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Mar 2026 10:53:23 +0000 Subject: [PATCH 05/17] debugged recipe.js and explained error --- Sprint-2/debug/recipe.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index 6cbdd22cd..80eedb523 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -4,12 +4,18 @@ // Each ingredient should be logged on a new line // How can you fix it? +// I predict this code will log: bruschetta serves 2 followed by ingredients: and then [object Object]. It won't show the actual list of ingredients. +// There are two main reasons this isn't working as intended: +// When you put ${recipe} inside a template literal, JavaScript doesn't know how to read the whole object into text, so it defaults to the placeholder [object Object]. We must point to the specific property, recipe.ingredients, instead. +// In addition to this; even if you point to recipe.ingredients, it's an array. If we want each ingredient to appear on a new line to meet the requirements, we will need to use the .join("\n") method. The \n acts as a newline character. + const recipe = { title: "bruschetta", serves: 2, ingredients: ["olive oil", "tomatoes", "salt", "pepper"], }; +const formattedIngredients = recipe.ingredients.join("\n"); console.log(`${recipe.title} serves ${recipe.serves} ingredients: -${recipe}`); +${formattedIngredients}`); From 576cd1fabf89e26c8131d9ac95ccacef5967cf92 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Wed, 18 Mar 2026 10:36:32 +0000 Subject: [PATCH 06/17] implemented function for contains.js --- Sprint-2/implement/contains.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index cd779308a..60e1d2f61 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,3 +1,11 @@ -function contains() {} +function contains(obj, propertyName) { + // 1. Check if 'obj' is a valid object and NOT an array + if (typeof obj !== "object" || obj === null || Array.isArray(obj)) { + return false; + } + + // 2. Check if the propertyName exists as a key in the object + return propertyName in obj; +} module.exports = contains; From 91faef29592f6f084789dd77414629eb8505c711 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Mon, 23 Mar 2026 10:30:59 +0000 Subject: [PATCH 07/17] add tests for contains function to validate behavior with empty objects, existing properties, non-existent properties, arrays, and null/undefined inputs --- Sprint-2/implement/contains.test.js | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 326bdb1f2..606b50557 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -20,16 +20,44 @@ as the object doesn't contains a key of 'c' // Given an empty object // When passed to contains // Then it should return false -test.todo("contains on empty object returns false"); +test("returns false when empty object", () => { + const input = {}; + const result = contains(input, "a"); + expect(result).toBe(false); +}); // Given an object with properties // When passed to contains with an existing property name // Then it should return true +test("returns true when the property exists in the object", () => { + const input = { firstName: "Alex", age: 30 }; + const result = contains(input, "firstName"); + expect(result).toBe(true); +}); + // Given an object with properties // When passed to contains with a non-existent property name // Then it should return false +test("returns false when the property does not exist in the object", () => { + const input = { firstName: "Alex", age: 30 }; + const result = contains(input, "lastName"); + expect(result).toBe(false); +}); + // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error + +test("returns false when the input is an array instead of an object", () => { + const input = [1, 2, 3]; + const result = contains(input, "0"); // Even though index 0 exists, it's an array + expect(result).toBe(false); +}); + +// 5. Given null or other types +test("returns false when the input is null or undefined", () => { + expect(contains(null, "prop")).toBe(false); + expect(contains(undefined, "prop")).toBe(false); +}); From 8a037f65a539470745c259d8ba39f250af57e659 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Wed, 25 Mar 2026 10:27:09 +0000 Subject: [PATCH 08/17] implement createLookup function to map country-currency pairs --- Sprint-2/implement/lookup.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index a6746e07f..5c2d38e9b 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -1,5 +1,14 @@ -function createLookup() { - // implementation here +function createLookup(countryCurrencyPairs) { + const lookup = {}; + + for (const pair of countryCurrencyPairs) { + const country = pair[0]; + const currency = pair[1]; + + lookup[country] = currency; + } + + return lookup; } module.exports = createLookup; From 4c7f534ce820f7fc9bc497892d07b64393be8de6 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Thu, 26 Mar 2026 09:34:35 +0000 Subject: [PATCH 09/17] refactor parseQueryString to improve handling of query strings and ensure proper decoding of keys and values --- Sprint-2/implement/querystring.js | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 45ec4e5f3..e5f7044b7 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -1,13 +1,44 @@ function parseQueryString(queryString) { const queryParams = {}; - if (queryString.length === 0) { + if (typeof queryString !== "string") { return queryParams; } + + if (queryString.startsWith("?")) { + queryString = queryString.substring(1); + } + + if (queryString.trim() === "") { + return queryParams; + } + const keyValuePairs = queryString.split("&"); for (const pair of keyValuePairs) { - const [key, value] = pair.split("="); - queryParams[key] = value; + if (!pair) continue; + + const equalIndex = pair.indexOf("="); + + let key = pair; + let value = ""; + + if (equalIndex !== -1) { + key = pair.substring(0, equalIndex); + value = pair.substring(equalIndex + 1); + } + + key = decodeURIComponent(key); + value = decodeURIComponent(value); + + if (queryParams.hasOwnProperty(key)) { + if (Array.isArray(queryParams[key])) { + queryParams[key].push(value); + } else { + queryParams[key] = [queryParams[key], value]; + } + } else { + queryParams[key] = value; + } } return queryParams; From 5b679e3f24096ce17599579fa6cd32fcfc6f7aa7 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Thu, 26 Mar 2026 09:52:59 +0000 Subject: [PATCH 10/17] add tests for parseQueryString to cover edge cases and improve query string parsing --- Sprint-2/implement/querystring.test.js | 46 ++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index 3e218b789..308260e3f 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -3,10 +3,52 @@ // Below is one test case for an edge case the implementation doesn't handle well. // Fix the implementation for this test, 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("parses querystring values containing =", () => { expect(parseQueryString("equation=x=y+1")).toEqual({ - "equation": "x=y+1", + equation: "x=y+1", + }); +}); + +test("parses querystring values missing = sign", () => { + expect(parseQueryString("userId=101&username=jdoe&isActive")).toEqual({ + userId: "101", + username: "Aokorefe", + isActive: "", + }); +}); + +test("parses querystring values containing no key and value but only =", () => { + expect(parseQueryString("=&priority=high&taskId=42&=&=")).toEqual({ + priority: "high", + taskId: "42", + }); +}); + +test("parses querystring with encoded keys and values", () => { + expect( + parseQueryString( + "query=web%20design&location=San%20Francisco&query=ui%20ux" + ) + ).toEqual({ + query: ["web design", "ui ux"], + location: "London", + }); +}); + +test("parses querystring values containing repetitive keys", () => { + expect( + parseQueryString("tag=frontend&count=10&tag=backend&tag=devops&count=20") + ).toEqual({ + tag: ["frontend", "backend", "devops"], + count: ["10", "20"], + }); +}); + +test("parses querystring with leading ?", () => { + expect(parseQueryString("?search=javascript&sort=asc")).toEqual({ + search: "javascript", + sort: "asc", }); }); From 66e18bb5249fc42cb2aa4162c200c30f6f0532e0 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 28 Mar 2026 10:52:41 +0000 Subject: [PATCH 11/17] implement tally function to count occurrences of items in an array and validate input --- Sprint-2/implement/tally.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/tally.js b/Sprint-2/implement/tally.js index f47321812..c18f0ce86 100644 --- a/Sprint-2/implement/tally.js +++ b/Sprint-2/implement/tally.js @@ -1,3 +1,17 @@ -function tally() {} +function tally(items) { + // Check for valid input + if (!Array.isArray(items)) { + throw new Error("Input must be an array"); + } + + const counts = {}; + + for (const item of items) { + // If the item exists, increment; otherwise, initialize to 1 + counts[item] = (counts[item] || 0) + 1; + } + + return counts; +} module.exports = tally; From 53bf5023b4d76e530eec85fc1e9cf2308b7692db Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 28 Mar 2026 12:07:31 +0000 Subject: [PATCH 12/17] add tests for tally function to validate behavior with empty arrays, duplicate items, and invalid inputs --- Sprint-2/implement/tally.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 2ceffa8dd..40d036f77 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -23,12 +23,18 @@ const tally = require("./tally.js"); // 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", () => + 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 an array with duplicate items returns correct counts", () => + expect(tally(["a", "a", "b", "c"])).toEqual({ a: 2, b: 1, c: 1 })); // Given an invalid input like a string // When passed to tally // Then it should throw an error +test("tally throws an error when passed a string", () => { + expect(() => tally("not an array")).toThrow(); +}); From 38a2a36cd8bb6f48cca4047b87bbfd3a8720a54a Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 28 Mar 2026 12:39:16 +0000 Subject: [PATCH 13/17] fix invert function to correctly swap keys and values; added initial test file --- Sprint-2/interpret/invert.js | 11 ++++++++++- Sprint-2/interpret/invert.test.js | 0 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 Sprint-2/interpret/invert.test.js diff --git a/Sprint-2/interpret/invert.js b/Sprint-2/interpret/invert.js index bb353fb1f..5643d369e 100644 --- a/Sprint-2/interpret/invert.js +++ b/Sprint-2/interpret/invert.js @@ -10,20 +10,29 @@ function invert(obj) { const invertedObj = {}; for (const [key, value] of Object.entries(obj)) { - invertedObj.key = value; + invertedObj[value] = key; } return invertedObj; } // a) What is the current return value when invert is called with { a : 1 } +// { key: 1 } // b) What is the current return value when invert is called with { a: 1, b: 2 } +// { key: 2 } // c) What is the target return value when invert is called with {a : 1, b: 2} +// { "1": "a", "2": "b" } // c) What does Object.entries return? Why is it needed in this program? +// Object.entries returns an array of a given object's own enumerable string-keyed property [key, value] pairs. +// It is needed in this program to iterate over the key-value pairs of the input object and swap them to create the inverted object. // d) Explain why the current return value is different from the target output +// The current return value is different from the target output because the code is assigning +// the value to a property named "key" in the invertedObj, instead of using the actual key from the input object. +// This results in only the last key-value pair being stored in the invertedObj, and it does not correctly swap the keys and values as intended. // e) Fix the implementation of invert (and write tests to prove it's fixed!) +module.exports = invert; diff --git a/Sprint-2/interpret/invert.test.js b/Sprint-2/interpret/invert.test.js new file mode 100644 index 000000000..e69de29bb From 0ccf022649e6d0e9c2b9904b850002dcce054f2d Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 28 Mar 2026 13:00:08 +0000 Subject: [PATCH 14/17] add tests for invert function to validate key-value swapping and handle edge cases --- Sprint-2/interpret/invert.js | 5 +++++ Sprint-2/interpret/invert.test.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Sprint-2/interpret/invert.js b/Sprint-2/interpret/invert.js index 5643d369e..1eff02ff9 100644 --- a/Sprint-2/interpret/invert.js +++ b/Sprint-2/interpret/invert.js @@ -17,19 +17,24 @@ function invert(obj) { } // a) What is the current return value when invert is called with { a : 1 } + // { key: 1 } // b) What is the current return value when invert is called with { a: 1, b: 2 } + // { key: 2 } // c) What is the target return value when invert is called with {a : 1, b: 2} + // { "1": "a", "2": "b" } // c) What does Object.entries return? Why is it needed in this program? + // Object.entries returns an array of a given object's own enumerable string-keyed property [key, value] pairs. // It is needed in this program to iterate over the key-value pairs of the input object and swap them to create the inverted object. // d) Explain why the current return value is different from the target output + // The current return value is different from the target output because the code is assigning // the value to a property named "key" in the invertedObj, instead of using the actual key from the input object. // This results in only the last key-value pair being stored in the invertedObj, and it does not correctly swap the keys and values as intended. diff --git a/Sprint-2/interpret/invert.test.js b/Sprint-2/interpret/invert.test.js index e69de29bb..5d881a69f 100644 --- a/Sprint-2/interpret/invert.test.js +++ b/Sprint-2/interpret/invert.test.js @@ -0,0 +1,22 @@ +const invert = require("./invert"); + +describe("invert()", () => { + test("inverts a single key-value pair", () => { + expect(invert({ a: 1 })).toEqual({ 1: "a" }); + }); + + test("inverts multiple key-value pairs", () => { + expect(invert({ a: 1, b: 2 })).toEqual({ 1: "a", 2: "b" }); + }); + + test("handles an empty object", () => { + expect(invert({})).toEqual({}); + }); + + test("inverts an object with string values", () => { + expect(invert({ first: "John", last: "Doe" })).toEqual({ + Alex: "first", + Doe: "last", + }); + }); +}); From 1dd6d932df5015a5ca2a9d05f21852f66523f4c9 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 7 Apr 2026 10:39:49 +0100 Subject: [PATCH 15/17] reverted file back to original --- Sprint-3/alarmclock/index.html | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index f16f1bd6c..9feeaa775 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -2,19 +2,5 @@ - - - Title here - -
-

Time Remaining: 00:00

- - - - - -
- - From fa2ccd316caa48ad1e5956f7c2a84f71a334fe25 Mon Sep 17 00:00:00 2001 From: Alex-Os-Dev-Lab Date: Tue, 7 Apr 2026 10:53:14 +0100 Subject: [PATCH 16/17] Fix doctype declaration in index.html --- 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 9feeaa775..e3a31a1d3 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,4 +1,4 @@ - + From 90faf303de92af5a2e2e3eb57b2b59927bb7e026 Mon Sep 17 00:00:00 2001 From: Alex-Os-Dev-Lab Date: Tue, 7 Apr 2026 10:54:18 +0100 Subject: [PATCH 17/17] Delete Sprint-3/alarmclock/index.html --- Sprint-3/alarmclock/index.html | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 Sprint-3/alarmclock/index.html diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html deleted file mode 100644 index e3a31a1d3..000000000 --- a/Sprint-3/alarmclock/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - -