From 1d8957c82042cca34177f9ad64b074d41c0b9d3b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 10:29:12 +0100 Subject: [PATCH 01/94] Add hello_world.js file --- prep/hello_world.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/hello_world.js diff --git a/prep/hello_world.js b/prep/hello_world.js new file mode 100644 index 000000000..e69de29bb From cb5fd1c539a93eb845d7382f1e5ba72c483853b0 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 10:32:20 +0100 Subject: [PATCH 02/94] Add hello_world.js file with initial console log --- prep/hello_world.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prep/hello_world.js b/prep/hello_world.js index e69de29bb..de8882976 100644 --- a/prep/hello_world.js +++ b/prep/hello_world.js @@ -0,0 +1 @@ +console.log("Hello World!"); \ No newline at end of file From 3dcb7b7d9e93946c205353e63f089fb2e4b4eaf1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 10:38:31 +0100 Subject: [PATCH 03/94] Add fact.js file --- prep/fact.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/fact.js diff --git a/prep/fact.js b/prep/fact.js new file mode 100644 index 000000000..e69de29bb From 14998aefee1f66afc2b5e4d35c6c9a12739d0a03 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 10:40:23 +0100 Subject: [PATCH 04/94] Add fun fact about sprints to fact.js --- prep/fact.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prep/fact.js b/prep/fact.js index e69de29bb..fa5cbb09f 100644 --- a/prep/fact.js +++ b/prep/fact.js @@ -0,0 +1 @@ +console.log("One fun fact about sprints is reading the instructions carefully, and making further research."); \ No newline at end of file From 4b9c01a3657c712b79ca005b57ee8f97a39655e2 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 10:42:31 +0100 Subject: [PATCH 05/94] Rename file fact.js to facts.js --- prep/{fact.js => facts.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename prep/{fact.js => facts.js} (100%) diff --git a/prep/fact.js b/prep/facts.js similarity index 100% rename from prep/fact.js rename to prep/facts.js From 386a826e84e137e39a9b46032acb590e7b26e4d0 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 11:25:59 +0100 Subject: [PATCH 06/94] Add greeting.js file --- prep/greeting.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/greeting.js diff --git a/prep/greeting.js b/prep/greeting.js new file mode 100644 index 000000000..e69de29bb From ed354a357b7691fa4e4955ecb72560707d352726 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 11:26:55 +0100 Subject: [PATCH 07/94] Add greeting message to greeting.js --- prep/greeting.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prep/greeting.js b/prep/greeting.js index e69de29bb..8b2e74583 100644 --- a/prep/greeting.js +++ b/prep/greeting.js @@ -0,0 +1 @@ +const greeting = "Hello there!"; \ No newline at end of file From 02c297f1815e8df2d43ea7aeada977d7ade0e002 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 11:29:58 +0100 Subject: [PATCH 08/94] Add console log for greeting message in greeting.js --- prep/greeting.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prep/greeting.js b/prep/greeting.js index 8b2e74583..2ee37185c 100644 --- a/prep/greeting.js +++ b/prep/greeting.js @@ -1 +1,2 @@ -const greeting = "Hello there!"; \ No newline at end of file +const greeting = "Hello there!"; +console.log(greeting); \ No newline at end of file From d3c778f173a471c8f051b08726362885f45859ac Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 11:39:40 +0100 Subject: [PATCH 09/94] Update greeting message to include name in greeting.js --- prep/greeting.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prep/greeting.js b/prep/greeting.js index 2ee37185c..9de68f666 100644 --- a/prep/greeting.js +++ b/prep/greeting.js @@ -1,2 +1,3 @@ -const greeting = "Hello there!"; -console.log(greeting); \ No newline at end of file +const greeting = "Hello there"; +const name = "Mr Moses"; +console.log(`${greeting}, ${name}!`); \ No newline at end of file From 041137983d755869ed51fa9109b9a8577c5316a0 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 11:53:17 +0100 Subject: [PATCH 10/94] Change greeting variable from const to let and update its value to "Good Morning" --- prep/greeting.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prep/greeting.js b/prep/greeting.js index 9de68f666..c13178591 100644 --- a/prep/greeting.js +++ b/prep/greeting.js @@ -1,3 +1,4 @@ -const greeting = "Hello there"; +let greeting = "Hello there"; +greeting = "Good Morning"; const name = "Mr Moses"; console.log(`${greeting}, ${name}!`); \ No newline at end of file From c6ad8eb5484346eb713dc9351b9e5b00f2458f1c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 12:01:46 +0100 Subject: [PATCH 11/94] Add boolean.js file --- prep/boolean.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/boolean.js diff --git a/prep/boolean.js b/prep/boolean.js new file mode 100644 index 000000000..e69de29bb From d2880fb4bb027c18b9f98cf4ec6d3145daa40896 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 12:21:23 +0100 Subject: [PATCH 12/94] Add boolean.js with initial console log comparisons --- prep/boolean.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/prep/boolean.js b/prep/boolean.js index e69de29bb..5cf610ff1 100644 --- a/prep/boolean.js +++ b/prep/boolean.js @@ -0,0 +1,13 @@ +console.log(42 === 10 + 32); + +console.log(10 * 5 === 60); + +console.log("hello" === "hello"); + +console.log("CYF" === "cyf"); + +const homeTown = "Newcastle" +//homeTown === "Liverpool" +console.log("homeTown" === "Liverpool") + +console.log(42 === 42) \ No newline at end of file From 2bddb02ab5d0030f289ec740a76aff60af3a5f27 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 14 Sep 2026 12:30:56 +0100 Subject: [PATCH 13/94] Add additional comparison console logs in boolean.js --- prep/boolean.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/prep/boolean.js b/prep/boolean.js index 5cf610ff1..a3c3268bc 100644 --- a/prep/boolean.js +++ b/prep/boolean.js @@ -7,7 +7,11 @@ console.log("hello" === "hello"); console.log("CYF" === "cyf"); const homeTown = "Newcastle" -//homeTown === "Liverpool" +homeTown === "Liverpool" console.log("homeTown" === "Liverpool") -console.log(42 === 42) \ No newline at end of file +console.log(42 === 42) + +console.log(42 === "42") + +console.log(42 == "42") \ No newline at end of file From 3f06814d56ae29252ef12e5da34583de0d09847e Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:09:50 +0100 Subject: [PATCH 14/94] Add passwordChecker.js file --- prep/passwordChecker.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/passwordChecker.js diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js new file mode 100644 index 000000000..e69de29bb From 1b3d99b169ca11a0b265aad1a3cdb2ff4dfcc0c8 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:18:44 +0100 Subject: [PATCH 15/94] Add password validation logic in passwordChecker.js --- prep/passwordChecker.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index e69de29bb..3e5192922 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -0,0 +1,6 @@ +const password="secretword123"; +const userInput="secretword123"; + +if(userInput === password){ + console.log("Correct password entered"); +} \ No newline at end of file From 56326fbbe1eb147950e7d8349ee7ed6315d27842 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:24:39 +0100 Subject: [PATCH 16/94] Add else statement to password validation logic --- prep/passwordChecker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index 3e5192922..37774913f 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -3,4 +3,6 @@ const userInput="secretword123"; if(userInput === password){ console.log("Correct password entered"); +} else{ + console.log("Incorrect password!"); } \ No newline at end of file From cae89270b31e6c298f529c08dae4056892fb7580 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:25:44 +0100 Subject: [PATCH 17/94] Update userInput for password validation test --- prep/passwordChecker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index 37774913f..2c341f2a0 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -1,5 +1,5 @@ const password="secretword123"; -const userInput="secretword123"; +const userInput="thisiswrong"; if(userInput === password){ console.log("Correct password entered"); From ad792cdced65b774a0866a5ffbf438494a417a9b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:37:47 +0100 Subject: [PATCH 18/94] Add adminPassword variable in passwordChecker.js --- prep/passwordChecker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index 2c341f2a0..a669c3a96 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -1,8 +1,11 @@ const password="secretword123"; const userInput="thisiswrong"; +const adminPassword="override"; if(userInput === password){ console.log("Correct password entered"); -} else{ +} + +else{ console.log("Incorrect password!"); } \ No newline at end of file From 31d84260140c9e2f55546548360c1d91afc762f4 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:41:11 +0100 Subject: [PATCH 19/94] Add else if condition to password validation logic in passwordChecker.js --- prep/passwordChecker.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index a669c3a96..6cb451a19 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -5,7 +5,9 @@ const adminPassword="override"; if(userInput === password){ console.log("Correct password entered"); } - +else if(userInput === adminPassword){ + console.log("Admin access granted"); +} else{ console.log("Incorrect password!"); } \ No newline at end of file From 0f097a321ef29cb0e17d48d21e861303b3113525 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:48:42 +0100 Subject: [PATCH 20/94] Add exercise.js file --- prep/exercise.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/exercise.js diff --git a/prep/exercise.js b/prep/exercise.js new file mode 100644 index 000000000..e69de29bb From 1d56388d621e31cf1808254164d07c271d8841f1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:53:12 +0100 Subject: [PATCH 21/94] Remove unused exercise.js file --- prep/exercise.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 prep/exercise.js diff --git a/prep/exercise.js b/prep/exercise.js deleted file mode 100644 index e69de29bb..000000000 From 220a7144128de6bedf4ff3be295cb5f7b855a3cc Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:56:48 +0100 Subject: [PATCH 22/94] Add response variable declaration in passwordChecker.js --- prep/passwordChecker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index 6cb451a19..c6b27b4bc 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -1,6 +1,7 @@ const password="secretword123"; const userInput="thisiswrong"; const adminPassword="override"; +const response=""; if(userInput === password){ console.log("Correct password entered"); From 762e97f6b1edbc67277ea01d71f81ed1d4b07e4d Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 15 Sep 2026 23:58:58 +0100 Subject: [PATCH 23/94] Update else condition to assign response message for incorrect password in passwordChecker.js --- prep/passwordChecker.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index c6b27b4bc..b75a9d2a7 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -10,5 +10,5 @@ else if(userInput === adminPassword){ console.log("Admin access granted"); } else{ - console.log("Incorrect password!"); -} \ No newline at end of file + response="Incorrect password!"; +} From 39b87c37dcd22a10e7e7c53e96867b3650c4f051 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 16 Sep 2026 00:00:50 +0100 Subject: [PATCH 24/94] Log response message for incorrect password in passwordChecker.js --- prep/passwordChecker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index b75a9d2a7..2b2f6a351 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -12,3 +12,4 @@ else if(userInput === adminPassword){ else{ response="Incorrect password!"; } +console.log(response); \ No newline at end of file From 3a1178c5b0e40d2d10bab450ea1f10ed5c3c04e1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 16 Sep 2026 08:16:59 +0100 Subject: [PATCH 25/94] Change response declaration from const to let in passwordChecker.js --- prep/passwordChecker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js index 2b2f6a351..7a67f0f6a 100644 --- a/prep/passwordChecker.js +++ b/prep/passwordChecker.js @@ -1,7 +1,7 @@ const password="secretword123"; const userInput="thisiswrong"; const adminPassword="override"; -const response=""; +let response=""; if(userInput === password){ console.log("Correct password entered"); From 9558f43dfcab97c6174d9626fd78d4fbfbf9af4c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 21 Sep 2026 11:33:49 +0100 Subject: [PATCH 26/94] Add prediction comment explaining SyntaxError in 0.js --- Sprint-3/1-key-errors/0.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..de6d6b834 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,5 +1,7 @@ // Predict and explain first... // =============> write your prediction here +// Prediction +// A SyntaxError is thrown with message: Identifier 'str' has already been declared // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring From 667b02a6f70b3f0c32d9b080602089f91032f79d Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 21 Sep 2026 11:35:40 +0100 Subject: [PATCH 27/94] Call the capitalise function with a test string --- Sprint-3/1-key-errors/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index de6d6b834..8524fab09 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -10,6 +10,6 @@ function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } - +capitalise("moses"); // =============> write your explanation here // =============> write your new code here From 0dcdd7fe5a56f663328814866ae1f2b61ab657bc Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 21 Sep 2026 11:38:16 +0100 Subject: [PATCH 28/94] Add comment about SyntaxError in 0.js --- Sprint-3/1-key-errors/0.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 8524fab09..600023a63 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -5,6 +5,7 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring +// Error message interpreted ====> The error message simply means the name 'str' was declared twice in the same scope function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; From f76aa55ea263ea831e52a4cc4739a89e6c5f8688 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 21 Sep 2026 11:48:55 +0100 Subject: [PATCH 29/94] Add explanation for SyntaxError in capitalise function --- Sprint-3/1-key-errors/0.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 600023a63..fb178ba00 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -13,4 +13,7 @@ function capitalise(str) { } capitalise("moses"); // =============> write your explanation here +// The error here is because the parameter 'str' and the variable 'let str' share the same name in he same scope, thus the SyntaxError. +// To fix this error, I could either give the variable a different name or reassign the parameter 'str' without 'let', since no new declaration is made + // =============> write your new code here From 5433734ab6011d4308b21996f406730926dcd39a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 21 Sep 2026 11:50:41 +0100 Subject: [PATCH 30/94] Refactor capitalise function to avoid SyntaxError by renaming variable --- Sprint-3/1-key-errors/0.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index fb178ba00..c2580f228 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -7,13 +7,18 @@ // interpret the error message and figure out why an error is occurring // Error message interpreted ====> The error message simply means the name 'str' was declared twice in the same scope -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} -capitalise("moses"); +// function capitalise(str) { +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } +// capitalise("moses"); // =============> write your explanation here // The error here is because the parameter 'str' and the variable 'let str' share the same name in he same scope, thus the SyntaxError. // To fix this error, I could either give the variable a different name or reassign the parameter 'str' without 'let', since no new declaration is made // =============> write your new code here +function capitalise(str) { + let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`; + return capitalised; +} +console.log(capitalise("moses")); \ No newline at end of file From 24548db90f7a06539e915fda778154df67864755 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Mon, 21 Sep 2026 11:54:25 +0100 Subject: [PATCH 31/94] Add refactored capitalise function to remove variable declaration conflict --- Sprint-3/1-key-errors/0.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index c2580f228..572aaf123 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -17,8 +17,14 @@ // To fix this error, I could either give the variable a different name or reassign the parameter 'str' without 'let', since no new declaration is made // =============> write your new code here +// function capitalise(str) { +// let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`; +// return capitalised; +// } +// console.log(capitalise("moses")); +// | function capitalise(str) { - let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`; - return capitalised; + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; } console.log(capitalise("moses")); \ No newline at end of file From c094e79ca596ffb8fc6f9f9a6f72bf3894613bd2 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:30:06 +0100 Subject: [PATCH 32/94] Add prediction comment explaining potential SyntaxError in convertToPercentage function --- Sprint-3/1-key-errors/1.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..753a4b814 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,4 +1,5 @@ // Predict and explain first... +// My prediction is the program would throw a SyntaxError, because 'decimalNumber' has already been declared as a parameter and also has been declared as a new variable in the same scope // Why will an error occur when this program runs? // =============> write your prediction here From 15527436339f5af9fd44c79c460a60df0c4f6709 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:34:28 +0100 Subject: [PATCH 33/94] Add explanation for potential SyntaxError in convertToPercentage function --- Sprint-3/1-key-errors/1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 753a4b814..87a40f337 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -3,10 +3,12 @@ // Why will an error occur when this program runs? // =============> write your prediction here +//An error will occur because 'const decimalNumber = 0.5' clashes with the parameter of the same name. // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { + // const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; From 9f517e7525b4a2cf104ee617fa8e401c3e5d0b61 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:36:16 +0100 Subject: [PATCH 34/94] Add explanatory comment for parameter shadowing in convertToPercentage function --- Sprint-3/1-key-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 87a40f337..877c864b5 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -8,7 +8,7 @@ // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - // + // The parameter 'decimalNumber' is created as a variable inside the function's scope. const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; From 36c8ab9e9ecd6eb16f5b1156e4cb8b5660359065 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:41:57 +0100 Subject: [PATCH 35/94] Add comments to clarify variable declaration conflict in convertToPercentage function --- Sprint-3/1-key-errors/1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 877c864b5..f1c21d361 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -10,6 +10,8 @@ function convertToPercentage(decimalNumber) { // The parameter 'decimalNumber' is created as a variable inside the function's scope. const decimalNumber = 0.5; + // tries to declare new variable called 'decimalNumber' in the same scope, where one already exists as a parameter + // cannot declare same name twice in one scope with 'const' const percentage = `${decimalNumber * 100}%`; return percentage; From ff1d8b80afe80cc67d7413ef11ce9e6a5cf19edf Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:48:12 +0100 Subject: [PATCH 36/94] Add comments to clarify scope of 'decimalNumber' variable in convertToPercentage function --- Sprint-3/1-key-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f1c21d361..cb5e42c32 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -16,8 +16,9 @@ function convertToPercentage(decimalNumber) { return percentage; } - +// As a result of the conflict nothing runs. console.log(decimalNumber); +// This line is outside the function and would not parse, as 'decimalNumber' only exists inside 'convertToPercentage' as a parameter. // =============> write your explanation here From 8f96ad7badb65594397d2f2c43237ac00535ed67 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:50:45 +0100 Subject: [PATCH 37/94] Add clarification comment on variable scope for function parameters --- Sprint-3/1-key-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index cb5e42c32..f6aeab6b2 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -21,6 +21,7 @@ console.log(decimalNumber); // This line is outside the function and would not parse, as 'decimalNumber' only exists inside 'convertToPercentage' as a parameter. // =============> write your explanation here - +// Parameters and variables declared inside a function cannot be accessed outside it. + // Finally, correct the code to fix the problem // =============> write your new code here From 31d174286e33ac2f7250862385e18a2a26e456f1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 18:51:34 +0100 Subject: [PATCH 38/94] Comment out code in convertToPercentage function to prevent SyntaxError due to variable declaration conflict --- Sprint-3/1-key-errors/1.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f6aeab6b2..324f00361 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -7,21 +7,21 @@ // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { - // The parameter 'decimalNumber' is created as a variable inside the function's scope. - const decimalNumber = 0.5; - // tries to declare new variable called 'decimalNumber' in the same scope, where one already exists as a parameter - // cannot declare same name twice in one scope with 'const' - const percentage = `${decimalNumber * 100}%`; +// function convertToPercentage(decimalNumber) { +// // The parameter 'decimalNumber' is created as a variable inside the function's scope. +// const decimalNumber = 0.5; +// // tries to declare new variable called 'decimalNumber' in the same scope, where one already exists as a parameter +// // cannot declare same name twice in one scope with 'const' +// const percentage = `${decimalNumber * 100}%`; - return percentage; -} -// As a result of the conflict nothing runs. -console.log(decimalNumber); -// This line is outside the function and would not parse, as 'decimalNumber' only exists inside 'convertToPercentage' as a parameter. +// return percentage; +// } +// // As a result of the conflict nothing runs. +// console.log(decimalNumber); +// // This line is outside the function and would not parse, as 'decimalNumber' only exists inside 'convertToPercentage' as a parameter. // =============> write your explanation here // Parameters and variables declared inside a function cannot be accessed outside it. - + // Finally, correct the code to fix the problem // =============> write your new code here From e2a617b9f5fe5b5f87281e575ff57b2bc5dbd6ae Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:03:04 +0100 Subject: [PATCH 39/94] Implement convertToPercentage function to calculate percentage from decimal input --- Sprint-3/1-key-errors/1.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 324f00361..28d87ec58 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -25,3 +25,8 @@ // Finally, correct the code to fix the problem // =============> write your new code here +function convertToPercentage(decimalNumber){ + const percentage = `${decimalNumber * 100}%`; + return percentage; +} +console.log(convertToPercentage(0.5)); \ No newline at end of file From 8e24d75a57ba3c70d6015289e856936af603a04c Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:16:17 +0100 Subject: [PATCH 40/94] Add comment to clarify parameter usage in square function --- Sprint-3/1-key-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..4b6664499 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,6 +1,6 @@ // Predict and explain first BEFORE you run any code... - +// The parameter is written as a value instead of a variable name // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here From f2a0d61570395be412dbe4b372083769e5a30575 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:17:40 +0100 Subject: [PATCH 41/94] Add comment to indicate expected SyntaxError in square function --- Sprint-3/1-key-errors/2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 4b6664499..6f2b4a09a 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -4,6 +4,7 @@ // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here +// The program will throw a SyntaxError function square(3) { return num * num; From ca723f9bb82460584d24cd4e62d217aa502df63a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:18:50 +0100 Subject: [PATCH 42/94] Add expected SyntaxError message for square function parameter --- Sprint-3/1-key-errors/2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 6f2b4a09a..fd483cd53 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -11,6 +11,7 @@ function square(3) { } // =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here From 409baf985ef162cb8b7f49c4c11ffe43ee0c46a9 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:27:50 +0100 Subject: [PATCH 43/94] Add explanation for SyntaxError in square function parameter --- Sprint-3/1-key-errors/2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index fd483cd53..106209bbc 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -14,6 +14,8 @@ function square(3) { // SyntaxError: Unexpected number // =============> explain this error message here +// In the 'function square(3)' JavaScript parser expected a valid parameter name it could use as a variable +// Since '3' is a number literal, not a valid identifier, the parser cannot understand it and throws a syntax error. // Finally, correct the code to fix the problem From c53c5ed6d012b2a743fc8363bbb70256303db4c7 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:28:47 +0100 Subject: [PATCH 44/94] Comment out square function to correct SyntaxError --- Sprint-3/1-key-errors/2.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 106209bbc..32d529933 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -6,9 +6,9 @@ // =============> write your prediction of the error here // The program will throw a SyntaxError -function square(3) { - return num * num; -} +// function square(3) { +// return num * num; +// } // =============> write the error message here // SyntaxError: Unexpected number From c50dd380d4ca9d035d23a2d24a1cdc53f25f41d4 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:30:11 +0100 Subject: [PATCH 45/94] Implement square function to correctly return the square of a number --- Sprint-3/1-key-errors/2.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 32d529933..42bb3f65c 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -20,5 +20,9 @@ // Finally, correct the code to fix the problem // =============> write your new code here +function square(n){ + return n * n; +} +console.log(square(77)); From b4452ffcfe997f84e8dca6316f61f36addb4f776 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 19:48:12 +0100 Subject: [PATCH 46/94] Add prediction for multiply function output --- Sprint-3/2-mandatory-debug/0.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..d3dc3b229 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,6 +1,8 @@ // Predict and explain first... // =============> write your prediction here +// My prediction is the output will be "The result of multiplying 10 and 32 is undefined" +// This occurs because 'multiply()' does not return anything function multiply(a, b) { console.log(a * b); From 329939aa2b8ef8dc5481558f90c8e20ce3ce84b8 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 20:04:10 +0100 Subject: [PATCH 47/94] Update prediction and explanation for multiply function output --- Sprint-3/2-mandatory-debug/0.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index d3dc3b229..03f657d4f 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,7 +1,7 @@ // Predict and explain first... // =============> write your prediction here -// My prediction is the output will be "The result of multiplying 10 and 32 is undefined" +// My prediction is '320' would be printed first followed by "The result of multiplying 10 and 32 is undefined" // This occurs because 'multiply()' does not return anything function multiply(a, b) { @@ -11,6 +11,11 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here +// The template literal calls 'multiply(10, 32) to build the string +// Inside multiply, 'console.log(a * b)' runs immediately, printing '320' +// This happens before the outer 'console.log' line finishes, because JavaScript has to evaluate 'multiply(10, 32)' first to know what to put in the template +// 'multiply's' function body only contains a 'console.log' statement without a 'return' keyword +// A function with no explicit return statement returns 'undefined' by default. // Finally, correct the code to fix the problem // =============> write your new code here From 33f9efb79efc949cf00c0b969978a7486692ae19 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 20:09:33 +0100 Subject: [PATCH 48/94] Refactor multiply function to return the product and update console log accordingly --- Sprint-3/2-mandatory-debug/0.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 03f657d4f..91cc921ba 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -4,11 +4,11 @@ // My prediction is '320' would be printed first followed by "The result of multiplying 10 and 32 is undefined" // This occurs because 'multiply()' does not return anything -function multiply(a, b) { - console.log(a * b); -} +// function multiply(a, b) { +// console.log(a * b); +// } -console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here // The template literal calls 'multiply(10, 32) to build the string @@ -19,3 +19,8 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // Finally, correct the code to fix the problem // =============> write your new code here +function multiply(a, b){ + return a * b; +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); From b89e5b7183be662998d2717e2040fda89ff39699 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:06:07 +0100 Subject: [PATCH 49/94] Add prediction comment for sum function output --- Sprint-3/2-mandatory-debug/1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..916a19702 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,5 +1,7 @@ // Predict and explain first... // =============> write your prediction here +// The code seems like it would log 'The sum of 10 and 32 is 42' since function 'sum(10, 32)' seems to add two numbers + function sum(a, b) { return; From 2d81e8b22067888de1613aa7fc82cd8fb5de5b98 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:14:25 +0100 Subject: [PATCH 50/94] Add explanation for sum function bug and unreachable code --- Sprint-3/2-mandatory-debug/1.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 916a19702..9fe1ff87d 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -11,5 +11,8 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +// When the code was run it logged 'The sum of 10 and 32 is undefined' +// The bug is in line 7 +// 'return' is automatically assigned a semi-colon if it is followed by a line break, making line 8 unreachable // Finally, correct the code to fix the problem // =============> write your new code here From 7fc88536f5d509627e1ae1c33db79406bf534aa8 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:15:01 +0100 Subject: [PATCH 51/94] Comment out the sum function and console log for debugging purposes --- Sprint-3/2-mandatory-debug/1.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 9fe1ff87d..e4632237c 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -3,16 +3,17 @@ // The code seems like it would log 'The sum of 10 and 32 is 42' since function 'sum(10, 32)' seems to add two numbers -function sum(a, b) { - return; - a + b; -} +// function sum(a, b) { +// return; +// a + b; +// } -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); +// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here // When the code was run it logged 'The sum of 10 and 32 is undefined' // The bug is in line 7 // 'return' is automatically assigned a semi-colon if it is followed by a line break, making line 8 unreachable + // Finally, correct the code to fix the problem // =============> write your new code here From fee9c3371983c5737153fb2f01ddb3b9e2314b83 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:16:37 +0100 Subject: [PATCH 52/94] Implement sum function to correctly return the sum of two numbers and update console log output --- Sprint-3/2-mandatory-debug/1.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index e4632237c..5f10b0079 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -17,3 +17,9 @@ // Finally, correct the code to fix the problem // =============> write your new code here +function sum(a, b){ + return ( + a + b + ); +} +console.log (`The sum of 10 and 32 is ${sum(10, 32)}`); From 17687160e8a4eb15e3aa790735f948f17f07f7f6 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:33:21 +0100 Subject: [PATCH 53/94] Add prediction comment for getLastDigit function output --- Sprint-3/2-mandatory-debug/2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..3ea08e158 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -2,6 +2,7 @@ // Predict the output of the following code: // =============> Write your prediction here +// I predict the output would print the last digits of '42', '105', and '806' because the function name is 'getLastDigit' and it's been called by the input values as arguments const num = 103; From d51b30d18e801e5cdcfb6b05bce6de607bf4ce1f Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:34:57 +0100 Subject: [PATCH 54/94] Add output for getLastDigit function --- Sprint-3/2-mandatory-debug/2.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 3ea08e158..87e4d8eb5 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -16,6 +16,10 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction // =============> write the output here +// The last digit of 42 is 3 +// The last digit of 105 is 3 +// The last digit of 806 is 3 + // Explain why the output is the way it is // =============> write your explanation here // Finally, correct the code to fix the problem From d2547c91564b1547b5410951e16692d77ee36840 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:41:04 +0100 Subject: [PATCH 55/94] Add explanation for getLastDigit function parameter issue --- Sprint-3/2-mandatory-debug/2.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 87e4d8eb5..1982bd06c 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -22,6 +22,9 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Explain why the output is the way it is // =============> write your explanation here +// The bug is in line 9, where 'getLastDigit()' is declared with no parameters +// Instead the function body reaches out to 'const num = 103' and disregards the values passed because the function does not declare any parameter + // Finally, correct the code to fix the problem // =============> write your new code here From 7d177236375ac6be6b92c7587b648775de498241 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:42:19 +0100 Subject: [PATCH 56/94] Comment out getLastDigit function and related console logs for debugging --- Sprint-3/2-mandatory-debug/2.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 1982bd06c..026e34fd5 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -4,15 +4,15 @@ // =============> Write your prediction here // I predict the output would print the last digits of '42', '105', and '806' because the function name is 'getLastDigit' and it's been called by the input values as arguments -const num = 103; +// const num = 103; -function getLastDigit() { - return num.toString().slice(-1); -} +// function getLastDigit() { +// return num.toString().slice(-1); +// } -console.log(`The last digit of 42 is ${getLastDigit(42)}`); -console.log(`The last digit of 105 is ${getLastDigit(105)}`); -console.log(`The last digit of 806 is ${getLastDigit(806)}`); +// console.log(`The last digit of 42 is ${getLastDigit(42)}`); +// console.log(`The last digit of 105 is ${getLastDigit(105)}`); +// console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction // =============> write the output here From 2fd1da46f8a7a3a43f97ee118f3d972ce8f69283 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:46:26 +0100 Subject: [PATCH 57/94] Implement getLastDigit function to return the last digit of a number and update console log outputs --- Sprint-3/2-mandatory-debug/2.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 026e34fd5..9dbfa71eb 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -28,5 +28,13 @@ // Finally, correct the code to fix the problem // =============> write your new code here +function getLastDigit(n){ + return n.toString().slice(-1) +} +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); + + // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 91327e667dfa59692958bdf9780919619021dfca Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 21:48:39 +0100 Subject: [PATCH 58/94] Add comment for irrelevant variable declaration in getLastDigit function --- Sprint-3/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 9dbfa71eb..32508566c 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -27,7 +27,7 @@ // Finally, correct the code to fix the problem // =============> write your new code here - +// const num = 103 ---- becomes irrelevant function getLastDigit(n){ return n.toString().slice(-1) } From feee6ba3871ebf86b75e7953cf8f19e2d4dcc097 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 22:51:06 +0100 Subject: [PATCH 59/94] Implement calculateBMI function to compute BMI based on weight and height, including error handling for invalid height --- Sprint-3/3-mandatory-implement/1-bmi.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..326c2411c 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,5 +15,12 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { + if (!height || height <= 0){ // to catch cases of undefined and null + throw new Error('Height must be greater than 0'); + } + const heightSquared = height ** 2; + const bmi = weight / heightSquared; + return bmi.toFixed(1); // rounds 'bmi' to 1 decimal place and converts to a string // return the BMI of someone based off their weight and height } +console.log(`The Body Mass Index is: ${calculateBMI(70, 1.73)}`); From acaa7de932bd364237b622f628e0b83a5dea71c4 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 22:55:17 +0100 Subject: [PATCH 60/94] Implement error handling clause for height parameter --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 326c2411c..5ed6462b2 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -23,4 +23,4 @@ function calculateBMI(weight, height) { return bmi.toFixed(1); // rounds 'bmi' to 1 decimal place and converts to a string // return the BMI of someone based off their weight and height } -console.log(`The Body Mass Index is: ${calculateBMI(70, 1.73)}`); +console.log(`The Body Mass Index is: ${calculateBMI(70, )}`); From efb0135df55f2e6ed701870dea8c8d82795773bc Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Tue, 22 Sep 2026 22:55:35 +0100 Subject: [PATCH 61/94] Fix console log to include height parameter in calculateBMI function --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 5ed6462b2..326c2411c 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -23,4 +23,4 @@ function calculateBMI(weight, height) { return bmi.toFixed(1); // rounds 'bmi' to 1 decimal place and converts to a string // return the BMI of someone based off their weight and height } -console.log(`The Body Mass Index is: ${calculateBMI(70, )}`); +console.log(`The Body Mass Index is: ${calculateBMI(70, 1.73)}`); From 8e26e40507cd9882e13bc350250619c9270b1d30 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 16:36:59 +0100 Subject: [PATCH 62/94] Implement toUpperSnakeCase function to convert strings to UPPER_SNAKE_CASE with input validation --- Sprint-3/3-mandatory-implement/2-cases.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..996569263 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,10 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase + +function toUpperSnakeCase(input){ + if (typeof input !== "string"){ + throw new Error("Input must be a string") + } + return input.trim().split(/\s+/).join("_").toUpperCase(); +} From 7ea0781fee2ba200f0b55bb009bc75314fef1b2f Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 16:40:16 +0100 Subject: [PATCH 63/94] Add console log to demonstrate toUpperSnakeCase function output --- Sprint-3/3-mandatory-implement/2-cases.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 996569263..727f8dd5b 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -21,3 +21,4 @@ function toUpperSnakeCase(input){ } return input.trim().split(/\s+/).join("_").toUpperCase(); } +console.log (toUpperSnakeCase("lord of the rings season 1 episode 1")); From e3228c5d471f6925cb04a39576ad1778b74b9c45 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 16:57:44 +0100 Subject: [PATCH 64/94] Implement toPounds function to convert pence strings to formatted pounds --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 10754da73..77bad529c 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,13 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs + +function toPounds(penceString){ + const penceStringWithoutTrailingP = penceString.subString(0, penceString.length - 1); + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + const pounds = paddedPenceNumberString.subString(0, paddedPenceNumberString.length - 2); + const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); + + return `£${pounds}.${pence}`; +} + From 93a453c5abe9f6bd30f755e989ea0a36dd7c6c91 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 17:02:40 +0100 Subject: [PATCH 65/94] Add additional test cases for toPounds function --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 77bad529c..490fe1ac9 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -6,11 +6,16 @@ // You should call this function a number of times to check it works for different inputs function toPounds(penceString){ - const penceStringWithoutTrailingP = penceString.subString(0, penceString.length - 1); + const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1); const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); - const pounds = paddedPenceNumberString.subString(0, paddedPenceNumberString.length - 2); + const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); return `£${pounds}.${pence}`; } +console.log(toPounds("77770p")); +console.log(toPounds("2570p")); +console.log(toPounds("399p")); +console.log(toPounds("77p")); +console.log(toPounds("0p")); From 4c052471adf59029c4fc78e3a5405aa9e5c9877b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 17:36:15 +0100 Subject: [PATCH 66/94] Add logging to track pad function calls in formatTimeDisplay --- Sprint-3/4-mandatory-interpret/time-format.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..23d608737 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,4 +1,6 @@ +let padCalls = 0; function pad(num) { + padCalls++; let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; @@ -14,6 +16,12 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } +for (const s of [8784, 77, 77777]){ + padCalls = 0; + const result = formatTimeDisplay(s); + console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); +} +console.log // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions From a5a7c63faa0a5ea4084386c9ef111a2e9265d9f0 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 17:41:43 +0100 Subject: [PATCH 67/94] Add explanation for pad function calls in formatTimeDisplay --- Sprint-3/4-mandatory-interpret/time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 23d608737..c20c7161c 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -30,6 +30,8 @@ console.log // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// The 'pad' function is called "three times" within the 'formatTimeDisplay' function +// The count will always be three because the 'return' statement contains three 'pad()' calls // Call formatTimeDisplay with an input of 61, now answer the following: From 0fe7ef9f3d1506562a838caec21f6ed38e6d7484 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 17:52:16 +0100 Subject: [PATCH 68/94] Commented-out code and logging related to pad function calls in time-format.js --- Sprint-3/4-mandatory-interpret/time-format.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c20c7161c..06c5638cd 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,6 +1,6 @@ -let padCalls = 0; +// let padCalls = 0; function pad(num) { - padCalls++; + // padCalls++; let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; @@ -16,12 +16,11 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } -for (const s of [8784, 77, 77777]){ - padCalls = 0; - const result = formatTimeDisplay(s); - console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); -} -console.log +// for (const s of [8784, 77, 77777]){ +// padCalls = 0; +// const result = formatTimeDisplay(s); +// console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); +// } // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions From ac9bd5d12a5cfc37a84145430b810e9c15879f1e Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 18:40:28 +0100 Subject: [PATCH 69/94] Implement function to track first number passed to pad function --- Sprint-3/4-mandatory-interpret/time-format.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 06c5638cd..b229cde17 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,6 +1,13 @@ // let padCalls = 0; +let padCallCount = 0; +let firstNum; + function pad(num) { // padCalls++; + padCallCount++; + if (padCallCount === 1){ + firstNum = num; + } let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; @@ -21,6 +28,8 @@ function formatTimeDisplay(seconds) { // const result = formatTimeDisplay(s); // console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); // } +formatTimeDisplay(61); +console.log("The value assigned to num on the first call to pad is:", firstNum); // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions From 2f14c92262e669cc743c7ff7e8938ac7aca498ec Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 18:48:10 +0100 Subject: [PATCH 70/94] Add explanation for first call to pad --- Sprint-3/4-mandatory-interpret/time-format.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index b229cde17..a89d16a37 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -45,6 +45,9 @@ console.log("The value assigned to num on the first call to pad is:", firstNum); // b) What is the value assigned to num when pad is called for the first time? // =============> write your answer here +// for the first call to pad, num is assigned the value of 'totalHours', which is '0' +// Since the template literal is evaluated from left to right, calling 'formatTimeDisplay(61)', the calls occur in this order: +// totalHours, remainingMinutes, and remainingSeconds // c) What is the return value of pad when it is called for the first time? // =============> write your answer here From b148d65ebfe1ea27142d0da3074d3326f0b023da Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 18:57:56 +0100 Subject: [PATCH 71/94] Commented-out code for firstNum assignment in pad function --- Sprint-3/4-mandatory-interpret/time-format.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index a89d16a37..388639fc9 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -5,13 +5,16 @@ let firstNum; function pad(num) { // padCalls++; padCallCount++; - if (padCallCount === 1){ - firstNum = num; - } + // if (padCallCount === 1){ + // firstNum = num; + // } let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; } + if (padCallCount === 1){ + firstReturn = numstring; + } return numString; } From fb5b6b5abc138f17331abcc2a134f551ecbe941b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:02:13 +0100 Subject: [PATCH 72/94] Implement function to track first pad return value --- Sprint-3/4-mandatory-interpret/time-format.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 388639fc9..614d92afe 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -13,7 +13,7 @@ function pad(num) { numString = "0" + numString; } if (padCallCount === 1){ - firstReturn = numstring; + firstReturn = numString; } return numString; } @@ -32,7 +32,7 @@ function formatTimeDisplay(seconds) { // console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); // } formatTimeDisplay(61); -console.log("The value assigned to num on the first call to pad is:", firstNum); +console.log("The return value of pad when called for first time is:", firstReturn); // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions From b6de5f3fcd5d8e568d4819158261dfa9a45508ce Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:08:48 +0100 Subject: [PATCH 73/94] Add explanation for first call to pad function return value --- Sprint-3/4-mandatory-interpret/time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 614d92afe..42bfbf2e5 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -54,6 +54,8 @@ console.log("The return value of pad when called for first time is:", firstRetur // c) What is the return value of pad when it is called for the first time? // =============> write your answer here +// For the first call to 'pad', 'num' is '0' +// The pad function will return '00' because it pads single-digit numbers with a leading zero // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer // =============> write your answer here From e642a44a4ac2fbf5f3bafb469cf6792c995d0eb9 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:15:09 +0100 Subject: [PATCH 74/94] Comment out unused variables and code in pad function --- Sprint-3/4-mandatory-interpret/time-format.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 42bfbf2e5..48351f0fa 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,10 +1,10 @@ // let padCalls = 0; -let padCallCount = 0; -let firstNum; +// let padCallCount = 0; +// let firstNum; function pad(num) { // padCalls++; - padCallCount++; + // padCallCount++; // if (padCallCount === 1){ // firstNum = num; // } @@ -12,9 +12,9 @@ function pad(num) { while (numString.length < 2) { numString = "0" + numString; } - if (padCallCount === 1){ - firstReturn = numString; - } + // if (padCallCount === 1){ + // firstReturn = numString; + // } return numString; } From 36e4464b60dd986fb2995d9d3cd28564e45d3434 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:18:54 +0100 Subject: [PATCH 75/94] Implement pad function to track last num value --- Sprint-3/4-mandatory-interpret/time-format.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 48351f0fa..dbb183578 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,6 +1,7 @@ // let padCalls = 0; // let padCallCount = 0; // let firstNum; +let lastNum; function pad(num) { // padCalls++; @@ -8,6 +9,7 @@ function pad(num) { // if (padCallCount === 1){ // firstNum = num; // } + lastNum = num; let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; @@ -32,7 +34,7 @@ function formatTimeDisplay(seconds) { // console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); // } formatTimeDisplay(61); -console.log("The return value of pad when called for first time is:", firstReturn); +console.log("The value assigned to num when pad is called for the last time is:", lastNum); // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions From 9953c8b95a5961d8c045922356beb2484633427b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:25:48 +0100 Subject: [PATCH 76/94] Add explanation for last call to pad function --- Sprint-3/4-mandatory-interpret/time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index dbb183578..96a7a47af 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -61,6 +61,8 @@ console.log("The value assigned to num when pad is called for the last time is:" // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer // =============> write your answer here +// The last call is 'pad(remainingSeconds)' which is '61 % 60' +// since 61 divided by 60 leaves a remainder of 1, it means the value '1' is assigned to 'num' in the last call of pad // e) What is the return value of pad when it is called for the last time in this program? Explain your answer // =============> write your answer here From ad65ef3aa69a0420cbe28975d2a98e7385344c83 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:29:34 +0100 Subject: [PATCH 77/94] Comment out lastNum variable and its assignment in pad function --- Sprint-3/4-mandatory-interpret/time-format.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 96a7a47af..d3f8d1e4e 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,7 +1,7 @@ // let padCalls = 0; // let padCallCount = 0; // let firstNum; -let lastNum; +// let lastNum; function pad(num) { // padCalls++; @@ -9,7 +9,7 @@ function pad(num) { // if (padCallCount === 1){ // firstNum = num; // } - lastNum = num; + // lastNum = num; let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; From 4f756c052a629276223bd4a379d68a761659d38e Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:34:34 +0100 Subject: [PATCH 78/94] Implement function to track last pad return value --- Sprint-3/4-mandatory-interpret/time-format.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index d3f8d1e4e..e79f90cb7 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -2,6 +2,7 @@ // let padCallCount = 0; // let firstNum; // let lastNum; +let lastReturn; function pad(num) { // padCalls++; @@ -17,6 +18,7 @@ function pad(num) { // if (padCallCount === 1){ // firstReturn = numString; // } + lastReturn = numString; return numString; } @@ -34,7 +36,7 @@ function formatTimeDisplay(seconds) { // console.log(`formatTimeDisplay(${s})==> ${result}| pad called ${padCalls} times `); // } formatTimeDisplay(61); -console.log("The value assigned to num when pad is called for the last time is:", lastNum); +console.log("The return value of pad when it is called for the last time is:", lastReturn); // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions From c5f7033c7b63ca5ab19ecbafe1b14e388e07f1c2 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 23 Sep 2026 19:38:36 +0100 Subject: [PATCH 79/94] Add explanation for return value of last pad call --- Sprint-3/4-mandatory-interpret/time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index e79f90cb7..593439cb3 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -68,3 +68,5 @@ console.log("The return value of pad when it is called for the last time is:", l // e) What is the return value of pad when it is called for the last time in this program? Explain your answer // =============> write your answer here +// The return value of pad when called for the last time is '01' +// since '1.toString()' is '1', the 'while' loop runs once and adds a '0' to the front, giving '01' From bfbaf1baf4f0c569ea6f3c7e647ae09958544091 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 24 Sep 2026 10:54:33 +0100 Subject: [PATCH 80/94] Comment out formatAs12HourClock function and its related assertions --- Sprint-3/5-stretch-extend/format-time.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..b7dc145aa 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -2,7 +2,7 @@ // Make sure to do the prep before you do the coursework // Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find. -function formatAs12HourClock(time) { +/*function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); if (hours > 12) { return `${hours - 12}:00 pm`; @@ -22,4 +22,5 @@ const targetOutput2 = "11:00 pm"; console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` -); +);*/ + From 6fc17adc5118b797c4ace519a07f3a71cce94c91 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 24 Sep 2026 11:08:28 +0100 Subject: [PATCH 81/94] Implement formatAs12HourClock function with input validation and time formatting --- Sprint-3/5-stretch-extend/format-time.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index b7dc145aa..7f5151602 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -24,3 +24,20 @@ console.assert( `current output: ${currentOutput2}, target output: ${targetOutput2}` );*/ +function formatAs12HourClock(time){ + if (typeof time != "string"){ + throw new Error (`Expected a string in "HH:MM" format, got ${typeof time}`); + } + const match = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(time); + if(!match){ + throw new RangeError(`Invalid time "${time}": expected 24-hour "HH:MM" (00:00 to 23:59)`); + } + + const hours = Number(match[1]); + const minutes = match[2]; + const period = hours < 12 ? "am" : "pm"; + const hours12 = hours % 12 === 0 ? 12 : hours % 12; + + return `${String(hours12).padStart(2, "0")}:${minutes} ${period}`; +} +console.log(formatAs12HourClock("23:20")) \ No newline at end of file From 38ee172ec81b68205f86dd5d111b1bc522d7141a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 24 Sep 2026 18:44:19 +0100 Subject: [PATCH 82/94] Add check functions for formatAs12HourClock to validate outputs and error handling --- Sprint-3/5-stretch-extend/format-time.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 7f5151602..716077608 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -40,4 +40,20 @@ function formatAs12HourClock(time){ return `${String(hours12).padStart(2, "0")}:${minutes} ${period}`; } -console.log(formatAs12HourClock("23:20")) \ No newline at end of file +console.log(formatAs12HourClock("23:20")) + +function check(input, targetOutput){ + const currentOutput = formatAs12HourClock(input); + console.assert(currentOutput === targetOutput, `input: ${input}. current output: ${currentOutput}, target output: ${targetOutput}`); +} + +function checkThrows(input){ + let threw = false; + try{ + formatAs12HourClock(input); + } + catch(error){ + threw = true; + } + console.assert(threw, `input: ${String(input)} should have thrown an error`); +} \ No newline at end of file From c72aac243161c739567f73883c28498027662669 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Thu, 24 Sep 2026 19:12:54 +0100 Subject: [PATCH 83/94] Refactor formatAs12HourClock function and add comprehensive test cases for various time formats and edge cases --- Sprint-3/5-stretch-extend/format-time.js | 40 ++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 716077608..62ba5f547 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -40,7 +40,7 @@ function formatAs12HourClock(time){ return `${String(hours12).padStart(2, "0")}:${minutes} ${period}`; } -console.log(formatAs12HourClock("23:20")) +console.log(formatAs12HourClock("23:00")) function check(input, targetOutput){ const currentOutput = formatAs12HourClock(input); @@ -56,4 +56,40 @@ function checkThrows(input){ threw = true; } console.assert(threw, `input: ${String(input)} should have thrown an error`); -} \ No newline at end of file +} + +// original tests +check("08:00", "08:00am"); +check("23:00", "11:00pm"); + +// midnight hours +check("00:00", "12:00am"); +check("00:30", "12:30am"); +check("00:59", "12:59am"); + +// mornings +check("01:00", "01:00am"); +check("09:59", "09:59am"); +check("10:05", "10:05am"); +check("11:59", "11:59am"); + +// noon +check("12:00", "12:00pm"); +check("12:01", "12:01pm"); +check("12:30", "12:30pm"); +check("12:59", "12:59pm"); + +// mid-day and evenings +check("13:00", "01:00pm"); +check("17:45", "05:45pm"); +check("22:10", "10:10pm"); +check("23:45", "11:45pm"); +check("23:59", "11:59pm"); + +// invalid times +checkThrows("24:00", "25:00", "12:60", "99:99", undefined, null, 800, ["08:00"]); + +// bad formatting +checkThrows("", "abc", "8:00", "0800", "08:00:00", " 08:00", "08:00 am"); + +console.log("Complete! No errors."); \ No newline at end of file From ebe4d77f59b735d379153dda7bc77f8704153515 Mon Sep 17 00:00:00 2001 From: Moses777 Date: Thu, 24 Sep 2026 19:31:23 +0100 Subject: [PATCH 84/94] Delete prep/boolean.js --- prep/boolean.js | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 prep/boolean.js diff --git a/prep/boolean.js b/prep/boolean.js deleted file mode 100644 index a3c3268bc..000000000 --- a/prep/boolean.js +++ /dev/null @@ -1,17 +0,0 @@ -console.log(42 === 10 + 32); - -console.log(10 * 5 === 60); - -console.log("hello" === "hello"); - -console.log("CYF" === "cyf"); - -const homeTown = "Newcastle" -homeTown === "Liverpool" -console.log("homeTown" === "Liverpool") - -console.log(42 === 42) - -console.log(42 === "42") - -console.log(42 == "42") \ No newline at end of file From be45ad627fd07fe2c70e68743180478e14f4a8e4 Mon Sep 17 00:00:00 2001 From: Moses777 Date: Thu, 24 Sep 2026 19:36:30 +0100 Subject: [PATCH 85/94] Delete prep/facts.js --- prep/facts.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 prep/facts.js diff --git a/prep/facts.js b/prep/facts.js deleted file mode 100644 index fa5cbb09f..000000000 --- a/prep/facts.js +++ /dev/null @@ -1 +0,0 @@ -console.log("One fun fact about sprints is reading the instructions carefully, and making further research."); \ No newline at end of file From 42c8e3233453c85264b39e66040c7db69fb0768b Mon Sep 17 00:00:00 2001 From: Moses777 Date: Thu, 24 Sep 2026 19:36:58 +0100 Subject: [PATCH 86/94] Delete prep directory --- prep/greeting.js | 4 ---- prep/hello_world.js | 1 - prep/passwordChecker.js | 15 --------------- 3 files changed, 20 deletions(-) delete mode 100644 prep/greeting.js delete mode 100644 prep/hello_world.js delete mode 100644 prep/passwordChecker.js diff --git a/prep/greeting.js b/prep/greeting.js deleted file mode 100644 index c13178591..000000000 --- a/prep/greeting.js +++ /dev/null @@ -1,4 +0,0 @@ -let greeting = "Hello there"; -greeting = "Good Morning"; -const name = "Mr Moses"; -console.log(`${greeting}, ${name}!`); \ No newline at end of file diff --git a/prep/hello_world.js b/prep/hello_world.js deleted file mode 100644 index de8882976..000000000 --- a/prep/hello_world.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello World!"); \ No newline at end of file diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js deleted file mode 100644 index 7a67f0f6a..000000000 --- a/prep/passwordChecker.js +++ /dev/null @@ -1,15 +0,0 @@ -const password="secretword123"; -const userInput="thisiswrong"; -const adminPassword="override"; -let response=""; - -if(userInput === password){ - console.log("Correct password entered"); -} -else if(userInput === adminPassword){ - console.log("Admin access granted"); -} -else{ - response="Incorrect password!"; -} -console.log(response); \ No newline at end of file From a81857306d49784e20dcb88aec16758a90f46b41 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 00:27:00 +0100 Subject: [PATCH 87/94] Refactor capitalise function to remove unnecessary variable assignment --- Sprint-3/1-key-errors/0.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 572aaf123..29ce9f80c 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -24,7 +24,6 @@ // console.log(capitalise("moses")); // | function capitalise(str) { - str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; + return `${str[0].toUpperCase()}${str.slice(1)}`; } console.log(capitalise("moses")); \ No newline at end of file From 117c886e1f1a68b4c4a3d81edf033db52e1e9b3a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 00:50:57 +0100 Subject: [PATCH 88/94] Refactor convertToPercentage function to simplify return statement --- Sprint-3/1-key-errors/1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 28d87ec58..454384a8c 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -26,7 +26,7 @@ // Finally, correct the code to fix the problem // =============> write your new code here function convertToPercentage(decimalNumber){ - const percentage = `${decimalNumber * 100}%`; - return percentage; + return `${decimalNumber * 100}%`; + } console.log(convertToPercentage(0.5)); \ No newline at end of file From ce0df580b0dbcb0ea578c87d1ea9bb8a8d1357e1 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 00:52:42 +0100 Subject: [PATCH 89/94] Rename parameter in square function for clarity --- Sprint-3/1-key-errors/2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 42bb3f65c..4e0a059c3 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -20,8 +20,8 @@ // Finally, correct the code to fix the problem // =============> write your new code here -function square(n){ - return n * n; +function square(number){ + return number * number; } console.log(square(77)); From ca134f6e8dea75ceec11cea4bb69c618cb9f68f7 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 00:56:55 +0100 Subject: [PATCH 90/94] Fix sum function return statement formatting for clarity --- Sprint-3/2-mandatory-debug/1.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 5f10b0079..38429c167 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -18,8 +18,6 @@ // Finally, correct the code to fix the problem // =============> write your new code here function sum(a, b){ - return ( - a + b - ); + return a + b; } console.log (`The sum of 10 and 32 is ${sum(10, 32)}`); From b5f6fa6fe7f55440f95a3aec9b299cdf90bbc9a0 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 02:07:46 +0100 Subject: [PATCH 91/94] Refactor calculateBMI function to directly return BMI value --- Sprint-3/3-mandatory-implement/1-bmi.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 326c2411c..a1303f609 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -19,8 +19,11 @@ function calculateBMI(weight, height) { throw new Error('Height must be greater than 0'); } const heightSquared = height ** 2; - const bmi = weight / heightSquared; + return weight / heightSquared; + } +function formatBMI(bmi){ return bmi.toFixed(1); // rounds 'bmi' to 1 decimal place and converts to a string // return the BMI of someone based off their weight and height -} -console.log(`The Body Mass Index is: ${calculateBMI(70, 1.73)}`); + } + + From 8613d97aea349d304ad98f7cc34bfdad91806b06 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 02:10:21 +0100 Subject: [PATCH 92/94] Add BMI calculation with structuring --- Sprint-3/3-mandatory-implement/1-bmi.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index a1303f609..2fff81b87 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -26,4 +26,6 @@ function formatBMI(bmi){ // return the BMI of someone based off their weight and height } - +const bmiFurMath = calculateBMI(70, 1.73) + 7; +const displayBMI = formatBMI(bmiFurMath); +console.log(`The Body Mass Index is: ${displayBMI}`); From 7a7e919d1c4ba62339a4e620aa79857c2b5aa08a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 14:06:23 +0100 Subject: [PATCH 93/94] Refactor toUpperSnakeCase function to use replaceAll for improved readability --- Sprint-3/3-mandatory-implement/2-cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 727f8dd5b..9be764f82 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -19,6 +19,6 @@ function toUpperSnakeCase(input){ if (typeof input !== "string"){ throw new Error("Input must be a string") } - return input.trim().split(/\s+/).join("_").toUpperCase(); + return input.trim().replaceAll(/\s+/g, "_").toUpperCase(); } console.log (toUpperSnakeCase("lord of the rings season 1 episode 1")); From 57ee644222606da78adbc2ee5acce35cae271081 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Fri, 25 Sep 2026 15:00:45 +0100 Subject: [PATCH 94/94] Refactor toPounds function for improved input handling --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 490fe1ac9..80681a68b 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -6,8 +6,11 @@ // You should call this function a number of times to check it works for different inputs function toPounds(penceString){ - const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1); - const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + let cleanNum = penceString.trim(); + if (cleanNum.toLowerCase().endsWith("p")){ + cleanNum = cleanNum.substring(0, cleanNum.length - 1); + } + const paddedPenceNumberString = cleanNum.padStart(3, "0"); const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); @@ -19,3 +22,6 @@ console.log(toPounds("2570p")); console.log(toPounds("399p")); console.log(toPounds("77p")); console.log(toPounds("0p")); +console.log(toPounds(" 50p ")); +console.log(toPounds("777")); +console.log(toPounds(""));