From cc0c7b72e09d4daa3bb63e8c265d2a64edd7a4c9 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 12:46:28 +0100 Subject: [PATCH 01/18] fixed syntax to access value for "houseNumber" key --- Sprint-2/debug/address.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 940a6af83..496ce84e3 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -1,4 +1,6 @@ // Predict and explain first... +// prediction before running code: This leads to an error as this isn't an array where values accessed via index/position. values should be accessed via keys/properties in objects. +//prediction after running code: logged out "undefined" for ${address[0]}` as this expression can't be matched with any property inside the object // This code should log out the houseNumber from the address object // but it isn't working... @@ -12,4 +14,4 @@ const address = { postcode: "XYZ 123", }; -console.log(`My house number is ${address[0]}`); +console.log(`My house number is ${address.houseNumber}`); From aa848542749ecb09c2c09b9d466946a7a13e009a Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 13:05:10 +0100 Subject: [PATCH 02/18] object now iterable & logs out all values. --- 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..aaea9e9f4 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -1,4 +1,6 @@ // Predict and explain first... +// prediction before running code: because accessing values of objects should've been done via dot notation or the square brackets method. +//prediction after running code: the "for.. of" method only works on iterable objects excluding "plain objects". "For...in" method could be used instead. // 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 @@ -11,6 +13,7 @@ const author = { alive: true, }; -for (const value of author) { - console.log(value); +for (const value in author) { + console.log(author[value]); } + From d20b68d0ce4e37fb3c6907326b78d7cc5231cd73 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 13:15:41 +0100 Subject: [PATCH 03/18] rephrased for better readability --- Sprint-2/debug/address.js | 2 +- Sprint-2/debug/author.js | 2 +- Sprint-2/debug/recipe.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 496ce84e3..be549d504 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -1,6 +1,6 @@ // Predict and explain first... // prediction before running code: This leads to an error as this isn't an array where values accessed via index/position. values should be accessed via keys/properties in objects. -//prediction after running code: logged out "undefined" for ${address[0]}` as this expression can't be matched with any property inside the object +//observations after running code: logged out "undefined" for ${address[0]}` as this expression can't be matched with any property inside the object // This code should log out the houseNumber from the address object // but it isn't working... diff --git a/Sprint-2/debug/author.js b/Sprint-2/debug/author.js index aaea9e9f4..346552b0d 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -1,6 +1,6 @@ // Predict and explain first... // prediction before running code: because accessing values of objects should've been done via dot notation or the square brackets method. -//prediction after running code: the "for.. of" method only works on iterable objects excluding "plain objects". "For...in" method could be used instead. +//observations after running code: the "for.. of" method only works on iterable objects excluding "plain objects". "For...in" method could be used instead. // 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 diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index 6cbdd22cd..a351adde7 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -1,4 +1,6 @@ // Predict and explain first... +// prediction before running code: this template literal expression: "${recipe}" won't give the expected results for the "ingredients" part. +// observations after running code: ${recipe}` evaluates to [object Object] // This program should log out the title, how many it serves and the ingredients. // Each ingredient should be logged on a new line From 9fe323fec7b58946d2f52e9907e6d290d89b5fe5 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 13:38:11 +0100 Subject: [PATCH 04/18] fixed bug & each ingredient displayed in new line --- Sprint-2/debug/recipe.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index a351adde7..0638e9010 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -1,6 +1,6 @@ // Predict and explain first... // prediction before running code: this template literal expression: "${recipe}" won't give the expected results for the "ingredients" part. -// observations after running code: ${recipe}` evaluates to [object Object] +// observations after running code: ${recipe}` evaluates to [object Object]. This is because template literal ALONE converts an object into a string with unreadable properties. // This program should log out the title, how many it serves and the ingredients. // Each ingredient should be logged on a new line @@ -12,6 +12,4 @@ const recipe = { ingredients: ["olive oil", "tomatoes", "salt", "pepper"], }; -console.log(`${recipe.title} serves ${recipe.serves} - ingredients: -${recipe}`); +console.log(`${recipe.title} serves ${recipe.serves} ingredients:\n${recipe.ingredients.join("\n")}`); From cfcb972312f72bdcd70f9cdcc409c2d55008e9d2 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 15:49:57 +0100 Subject: [PATCH 05/18] contains function now meets requirements --- Sprint-2/implement/contains.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index cd779308a..8b0e89e6a 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -1,3 +1,14 @@ -function contains() {} +function contains(object, property) { + if (typeof object !== "object" || object == null || Array.isArray(object)) { + return false; + } + if (Object.keys(object).length === 0) { + return false; + } else { + return object.hasOwnProperty(property); + } + + +} module.exports = contains; From ba1252d7115a0489a124b568264da4ab623bd8d0 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 17:37:42 +0100 Subject: [PATCH 06/18] Built tests to ensure function is working --- Sprint-2/implement/contains.test.js | 48 ++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index 326bdb1f2..e18e1867c 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -20,16 +20,62 @@ 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("contains on empty object returns false", () => { + + const currentOutput = contains({}, "2"); + const targetOutput = false; + expect(currentOutput).toEqual(targetOutput); +}); // Given an object with properties // When passed to contains with an existing property name // Then it should return true +const user = { + id: 101, + name: "Amina Yusuf", + email: "amina@example.com", + isVerified: true, +}; +test("an object contains an existing property name returns true", () => { + const currentOutput = contains(user, "name"); + const targetOutput = true; + expect(currentOutput).toEqual(targetOutput); +}); // Given an object with properties // When passed to contains with a non-existent property name // Then it should return false +const book = { + title: "Harry Potter and the Sorcerer's Stone", + author: "J.K. Rowling", + publishedYear: 1997, + genres: "Fantasy", + pages: 309 +}; + +test("an object doesn't contain a property name returns false", () => { + const currentOutput = contains(book, "series"); + const targetOutput = false; + expect(currentOutput).toEqual(targetOutput); +}); + // Given invalid parameters like an array // When passed to contains // Then it should return false or throw an error + +const programmingLanguages = ["JavaScript", "Python", "Java", "C++", "Go", "Rust", "Ruby"]; +const languages = null; +const name = "Hassan"; + +test("Returns false when invalid parameters are passed", () => { + const currentOutput = contains(programmingLanguages); + const targetOutput = false; + expect(currentOutput).toEqual(targetOutput); + const currentOutput1 = contains(languages, "null"); + const targetOutput1 = false; + expect(currentOutput1).toEqual(targetOutput1); + const currentOutput2 = contains(name, "Hassan"); + const targetOutput2 = false; + expect(currentOutput2).toEqual(targetOutput2); +}); From 0a0d73bc2175563bb9fc166100e1a406ca944a1a Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 21:08:32 +0100 Subject: [PATCH 07/18] implement country-code & currency function --- Sprint-2/implement/lookup.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/lookup.js b/Sprint-2/implement/lookup.js index a6746e07f..d24b0eff0 100644 --- a/Sprint-2/implement/lookup.js +++ b/Sprint-2/implement/lookup.js @@ -1,5 +1,6 @@ -function createLookup() { - // implementation here +function createLookup(array) { + return Object.fromEntries(array); + } module.exports = createLookup; From 161f6e430af8b1115b9495f79cd257d4403291f3 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 7 Jul 2025 21:20:04 +0100 Subject: [PATCH 08/18] test passed for country code/ currency function --- Sprint-2/implement/lookup.test.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/lookup.test.js b/Sprint-2/implement/lookup.test.js index 547e06c5a..28e4bab3d 100644 --- a/Sprint-2/implement/lookup.test.js +++ b/Sprint-2/implement/lookup.test.js @@ -1,6 +1,19 @@ const createLookup = require("./lookup.js"); -test.todo("creates a country currency code lookup for multiple codes"); +const countryCurrencyPairs = [["US", "USD"], ["GB", "GBP"], ["JP", "JPY"], ["NG", "NGN"], ["IN", "INR"], ["CA", "CAD"]]; + +test("creates a country currency code lookup for multiple codes", () => { + const currentOutput = createLookup(countryCurrencyPairs); + const targetOutput = { + US: "USD", + GB: "GBP", + JP: "JPY", + NG: "NGN", + IN: "INR", + CA: "CAD" +}; +expect(currentOutput).toEqual(targetOutput); +}); /* From d02455c949adbe588e205d37561aae27f3eade17 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Wed, 9 Jul 2025 12:42:10 +0100 Subject: [PATCH 09/18] created function to calc array's element's reps --- Sprint-2/implement/tally.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/tally.js b/Sprint-2/implement/tally.js index f47321812..ac72490c9 100644 --- a/Sprint-2/implement/tally.js +++ b/Sprint-2/implement/tally.js @@ -1,3 +1,11 @@ -function tally() {} +function tally(list) { + if (!Array.isArray(list)) { + throw new Error("Invalid input!"); + } + return list.reduce((rep, element) => { + rep[element] = (rep[element] || 0) + 1; + return rep; + }, {}); +} module.exports = tally; From 04f0e36e63cad21cf2b4eca7742b2995e3c96da2 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Wed, 9 Jul 2025 20:14:10 +0100 Subject: [PATCH 10/18] test for empty array passed --- Sprint-2/implement/tally.test.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 2ceffa8dd..76920bce6 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -23,7 +23,14 @@ 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"); + +const list = []; + +test("tally on an empty array returns an empty object", () => { + const currentOutput = tally(list); + const targetOutput = {}; + expect(currentOutput).toEqual(targetOutput); +}); // Given an array with duplicate items // When passed to tally From 029d264c61507f180838992f7c404ec23fd172ba Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Wed, 9 Jul 2025 20:21:08 +0100 Subject: [PATCH 11/18] array (with repeated to object) items test passed --- Sprint-2/implement/tally.test.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 76920bce6..1b38d4990 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -24,10 +24,10 @@ const tally = require("./tally.js"); // When passed to tally // Then it should return an empty object -const list = []; +const emptyArray = []; test("tally on an empty array returns an empty object", () => { - const currentOutput = tally(list); + const currentOutput = tally(emptyArray); const targetOutput = {}; expect(currentOutput).toEqual(targetOutput); }); @@ -36,6 +36,14 @@ test("tally on an empty array returns an empty object", () => { // When passed to tally // Then it should return counts for each unique item +const animals = ['cat', 'dog', 'cat', 'bird', 'dog', 'dog', 'rabbit', 'cat']; + +test("tally on an array returns an object with the frequency of each item as properties", () => { + const currentOutput = tally(animals); + const targetOutput = {cat: 3, dog: 3, bird: 1, rabbit: 1}; + expect(currentOutput).toEqual(targetOutput); +}); + // Given an invalid input like a string // When passed to tally // Then it should throw an error From 117cd92a9a0376491de9e057ea4a78de283878d7 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Wed, 9 Jul 2025 20:34:15 +0100 Subject: [PATCH 12/18] "throw error" test passed --- Sprint-2/implement/tally.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/implement/tally.test.js b/Sprint-2/implement/tally.test.js index 1b38d4990..2f2fb90e9 100644 --- a/Sprint-2/implement/tally.test.js +++ b/Sprint-2/implement/tally.test.js @@ -47,3 +47,12 @@ test("tally on an array returns an object with the frequency of each item as pro // Given an invalid input like a string // When passed to tally // Then it should throw an error + +test("tally throws an error when given invalid input", () => { + const name = "Hassan"; + const age = null; + const subjectsHobbies = {Math: "puzzles", Science: "experiments", Art: "drawing"}; + expect(() => tally(name)).toThrow("Invalid input!"); + expect(() => tally(age)).toThrow("Invalid input!"); + expect(() => tally(subjectsHobbies)).toThrow("Invalid input!"); +}); \ No newline at end of file From 88a80221d1d281fcd1fe9d88783bcf2b3d864cde Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 10 Jul 2025 17:41:42 +0100 Subject: [PATCH 13/18] implement function to pass several edge cases --- Sprint-2/implement/querystring.js | 16 +++++++++-- Sprint-2/implement/querystring.test.js | 38 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 45ec4e5f3..5f0054755 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -6,11 +6,21 @@ function parseQueryString(queryString) { const keyValuePairs = queryString.split("&"); for (const pair of keyValuePairs) { - const [key, value] = pair.split("="); - queryParams[key] = value; - } + const separatorIndex = pair.indexOf("="); + if (separatorIndex === -1) { + queryParams[pair] = ""; + } else { + const key = pair.slice(0, separatorIndex); + const value = pair.slice(separatorIndex + 1); + queryParams[key] = value; + } + } + return queryParams; } module.exports = parseQueryString; + + +console.log(parseQueryString("equation=x=y+1")); \ No newline at end of file diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index 3e218b789..c4050dce6 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -5,8 +5,44 @@ const parseQueryString = require("./querystring.js") +test("parses querystring values containing multiple '=' signs", () => { + expect(parseQueryString("name=JohnDoe&age=30&country=Canada&sort=recent&showDetails=true")).toEqual({ + name: "JohnDoe", + age: "30", + country: "Canada", + sort: "recent", + showDetails: "true" +}); +}); + + + +test("parses an empty querystring & returns an empty object", () => { + expect(parseQueryString("")).toEqual({}); +}); + + + + test("parses querystring values containing =", () => { expect(parseQueryString("equation=x=y+1")).toEqual({ - "equation": "x=y+1", + equation: "x=y+1", }); }); + + + + +test("parses querystring values without '=' & returns keys only", () => { + expect(parseQueryString("fullName")).toEqual({fullName: "" }); +}); + + + + +test("parses querystring with duplicate/repeated keys & returns the last key-value pair", () => { + expect(parseQueryString("haircut=buzzCut&haircut=mullet&haircut=lowFade&shaver=braun&shaver=philips&shaver=wahl")).toEqual({ + haircut: "lowFade", + shaver: "wahl", + }); +}); \ No newline at end of file From bbe68e7dbd11bc8c13b2c1357f14b96dc656a730 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Thu, 10 Jul 2025 23:20:50 +0100 Subject: [PATCH 14/18] answered Qs & fixed function to swap keys & values --- Sprint-2/interpret/invert.js | 44 +++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/Sprint-2/interpret/invert.js b/Sprint-2/interpret/invert.js index bb353fb1f..6e5f71e0f 100644 --- a/Sprint-2/interpret/invert.js +++ b/Sprint-2/interpret/invert.js @@ -17,13 +17,55 @@ 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 } +// b) What is the current return value when invert is called with +//{ 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? +// it returns an array of key-value pairs from an object. +//it's needed in order to loop through each key-value pairs of an object. // d) Explain why the current return value is different from the target output +// because line 13 is not written accordingly. The current arrangement always starts with keys and then values. +// Most importantly, there's a bug. Currently, it returns "key" as if it's a key/property name. Refer to (a & b) + + // e) Fix the implementation of invert (and write tests to prove it's fixed!) + +function invert(obj) { + const invertedObj = {}; + + for (const [key, value] of Object.entries(obj)) { + invertedObj[value] = key; + } + + return invertedObj; +} + + +const sports = { + soccer: "ball", + tennis: "racket", + basketball: "hoopBall", + baseball: "bat", + swimming: "goggles", +}; + +console.log(invert(sports)); + +// test("when 'invert' passed an object it returns the object with keys & values swapped.", () => { +// expect(invert(sports)).toEqual({ +// ball: "soccer", +// racket: "tennis", +// hoopBall: "basketball", +// bat: "baseball", +// goggles: "swimming", +// }); +// }); + + From 025f19c104643d87a1a3b24bd0ecce4be3273f40 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Sat, 12 Jul 2025 14:15:54 +0100 Subject: [PATCH 15/18] removed code lines that don't add anything. --- Sprint-2/implement/contains.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Sprint-2/implement/contains.js b/Sprint-2/implement/contains.js index 8b0e89e6a..2a710bf5c 100644 --- a/Sprint-2/implement/contains.js +++ b/Sprint-2/implement/contains.js @@ -2,13 +2,10 @@ function contains(object, property) { if (typeof object !== "object" || object == null || Array.isArray(object)) { return false; } - if (Object.keys(object).length === 0) { - return false; - } else { + return object.hasOwnProperty(property); } -} module.exports = contains; From a3c57497227000cf36050939a5703beb5f1a2771 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Sat, 12 Jul 2025 14:20:24 +0100 Subject: [PATCH 16/18] added index (serves as key) in array test --- Sprint-2/implement/contains.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/implement/contains.test.js b/Sprint-2/implement/contains.test.js index e18e1867c..1bc1eda87 100644 --- a/Sprint-2/implement/contains.test.js +++ b/Sprint-2/implement/contains.test.js @@ -69,7 +69,7 @@ const languages = null; const name = "Hassan"; test("Returns false when invalid parameters are passed", () => { - const currentOutput = contains(programmingLanguages); + const currentOutput = contains(programmingLanguages, "3"); const targetOutput = false; expect(currentOutput).toEqual(targetOutput); const currentOutput1 = contains(languages, "null"); From 5191ab867eefef2e88b0ed050d6cfa78c77d3442 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 14 Jul 2025 08:26:06 +0100 Subject: [PATCH 17/18] function now implemented to pass coded QSs test --- Sprint-2/implement/querystring.js | 6 +++--- Sprint-2/implement/querystring.test.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index 5f0054755..e5e46a1b7 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -3,6 +3,7 @@ function parseQueryString(queryString) { if (queryString.length === 0) { return queryParams; } + const keyValuePairs = queryString.split("&"); for (const pair of keyValuePairs) { @@ -11,12 +12,11 @@ function parseQueryString(queryString) { if (separatorIndex === -1) { queryParams[pair] = ""; } else { - const key = pair.slice(0, separatorIndex); - const value = pair.slice(separatorIndex + 1); + const key = decodeURIComponent(pair.slice(0, separatorIndex)); + const value = decodeURIComponent(pair.slice(separatorIndex + 1)); queryParams[key] = value; } } - return queryParams; } diff --git a/Sprint-2/implement/querystring.test.js b/Sprint-2/implement/querystring.test.js index c4050dce6..ed26cf03a 100644 --- a/Sprint-2/implement/querystring.test.js +++ b/Sprint-2/implement/querystring.test.js @@ -45,4 +45,13 @@ test("parses querystring with duplicate/repeated keys & returns the last key-val haircut: "lowFade", shaver: "wahl", }); -}); \ No newline at end of file +}); + + +test("parses an encoded querystring & returns decoded key-value pairs", () => { + expect(parseQueryString("name=John%20Doe&email=john.doe%40example.com&message=Hello%2C%20how%20are%20you%3F")).toEqual({ + name: "John Doe", + email: "john.doe@example.com", + message: "Hello, how are you?" + }) +}) \ No newline at end of file From 2331195b4ab8967d66cefd285147e215dc326d41 Mon Sep 17 00:00:00 2001 From: HassanOHOsman Date: Mon, 14 Jul 2025 08:30:02 +0100 Subject: [PATCH 18/18] improved indentation --- Sprint-2/implement/querystring.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-2/implement/querystring.js b/Sprint-2/implement/querystring.js index e5e46a1b7..3d8d2754b 100644 --- a/Sprint-2/implement/querystring.js +++ b/Sprint-2/implement/querystring.js @@ -10,11 +10,11 @@ function parseQueryString(queryString) { const separatorIndex = pair.indexOf("="); if (separatorIndex === -1) { - queryParams[pair] = ""; + queryParams[pair] = ""; } else { - const key = decodeURIComponent(pair.slice(0, separatorIndex)); - const value = decodeURIComponent(pair.slice(separatorIndex + 1)); - queryParams[key] = value; + const key = decodeURIComponent(pair.slice(0, separatorIndex)); + const value = decodeURIComponent(pair.slice(separatorIndex + 1)); + queryParams[key] = value; } } return queryParams;