From bd83096d8da33d0039815afcd1d832ac705c0209 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 25 Jun 2026 23:29:20 +0100 Subject: [PATCH 01/49] predicted that there will be a syntaxError --- Sprint-2/1-key-errors/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..22b0145468 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here /* there will be a syntax error because the variable str is being declared twice in the same scope. The first declaration is in the function parameter, and the second declaration is inside the function body. This will cause a conflict and result in an error. */ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring From c37175663f30a33992b2f73544ec01af62226ff5 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 25 Jun 2026 23:38:26 +0100 Subject: [PATCH 02/49] called the function with arguement --- Sprint-2/1-key-errors/0.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 22b0145468..28e6d02569 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -7,7 +7,9 @@ function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; + } +capitalise("Tobias"); -// =============> write your explanation here +// =============> write your explanation here /* when the function `capitalise` is called with the argument "Tobias", it tries to declare a new variable `str` inside the function body using `let`. However, `str` is already declared as a parameter of the function. In JavaScript, you cannot declare a variable with the same name in the same scope, which leads to a syntax error.*/ // =============> write your new code here From cd270fbbed8428da69946be8ec529ee47d54ac59 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 25 Jun 2026 23:45:30 +0100 Subject: [PATCH 03/49] interpreted the error message and suggested the fix --- Sprint-2/1-key-errors/0.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 28e6d02569..af4ac664b6 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -11,5 +11,6 @@ function capitalise(str) { } capitalise("Tobias"); -// =============> write your explanation here /* when the function `capitalise` is called with the argument "Tobias", it tries to declare a new variable `str` inside the function body using `let`. However, `str` is already declared as a parameter of the function. In JavaScript, you cannot declare a variable with the same name in the same scope, which leads to a syntax error.*/ +// =============> write your explanation here /* when the function `capitalise` is called with the argument "Tobias", it tries to declare a new variable `str` inside the function body using `let`. However, `str` is already declared as a parameter of the function. In JavaScript, you cannot declare a variable with the same name in the same scope, which leads to a syntax error and from the error message thus /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/0.js:8 + /*let str = `${str[0].toUpperCase()}${str.slice(1)}`;SyntaxError: Identifier 'str' has already been declared it is pointing at line 8 as where the syntax error occurred so to fix the error the value on line 8 will need to be reassigned and not redeclared */ // =============> write your new code here From 31f5daf5f6d6dfc812a3911191546c5d1a56518d Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 25 Jun 2026 23:47:15 +0100 Subject: [PATCH 04/49] commented out the original code so I can write the new code to fix the error --- Sprint-2/1-key-errors/0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index af4ac664b6..6e539ef026 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -4,12 +4,12 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { +/*function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } -capitalise("Tobias"); +capitalise("Tobias");*/ // =============> write your explanation here /* when the function `capitalise` is called with the argument "Tobias", it tries to declare a new variable `str` inside the function body using `let`. However, `str` is already declared as a parameter of the function. In JavaScript, you cannot declare a variable with the same name in the same scope, which leads to a syntax error and from the error message thus /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/0.js:8 /*let str = `${str[0].toUpperCase()}${str.slice(1)}`;SyntaxError: Identifier 'str' has already been declared it is pointing at line 8 as where the syntax error occurred so to fix the error the value on line 8 will need to be reassigned and not redeclared */ From 1d0572aa08bae4abc2372eca923325351df32b03 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 25 Jun 2026 23:50:37 +0100 Subject: [PATCH 05/49] wrote a new code that fixed the syntaxErrot and console the called function with argument tobias which worked --- Sprint-2/1-key-errors/0.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 6e539ef026..fe86965985 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -14,3 +14,9 @@ capitalise("Tobias");*/ // =============> write your explanation here /* when the function `capitalise` is called with the argument "Tobias", it tries to declare a new variable `str` inside the function body using `let`. However, `str` is already declared as a parameter of the function. In JavaScript, you cannot declare a variable with the same name in the same scope, which leads to a syntax error and from the error message thus /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/0.js:8 /*let str = `${str[0].toUpperCase()}${str.slice(1)}`;SyntaxError: Identifier 'str' has already been declared it is pointing at line 8 as where the syntax error occurred so to fix the error the value on line 8 will need to be reassigned and not redeclared */ // =============> write your new code here +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; + +} +console.log(capitalise("Tobias")); From 782cf84942cad98e7c189774875832b137a2c526 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 16:58:52 +0100 Subject: [PATCH 06/49] Predicted why an error will occur when the programm is run --- Sprint-2/1-key-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f4..7255e413be 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,7 +1,7 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> write your prediction here. /* Error will occur when this program is run because a variable already declared inside the function parameter , was redeclared inside the function body. Also the console.log function is calling the variable decimalNumber which is not defined in the global scope. */ // Try playing computer with the example to work out what is going on From 029282445c8ec395f6d3615969c0b2163e3cce4f Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:03:57 +0100 Subject: [PATCH 07/49] When the code was ran an error occured as preicted showing that the error occured at line 9 as pasted in the file --- Sprint-2/1-key-errors/1.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 7255e413be..36916ad0e6 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -15,6 +15,11 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // =============> write your explanation here +/* /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/1.js:9 + const decimalNumber = 0.5; + ^ + +SyntaxError: Identifier 'decimalNumber' has already been declared*/ // Finally, correct the code to fix the problem // =============> write your new code here From 99357d30c912a1596571fd5095b5679385a3ad1a Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:08:12 +0100 Subject: [PATCH 08/49] the error was fixed by reassignment instead of redeclaring the variable decimalNumber, and the refence error occurs to show that the variable decimalNumber is not a global varaible --- Sprint-2/1-key-errors/1.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 36916ad0e6..95a49d5dc3 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -6,7 +6,7 @@ // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; + decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; @@ -20,6 +20,11 @@ console.log(decimalNumber); ^ SyntaxError: Identifier 'decimalNumber' has already been declared*/ +/* /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/1.js:15 +console.log(decimalNumber); + ^ + +ReferenceError: decimalNumber is not defined*/ // Finally, correct the code to fix the problem // =============> write your new code here From bb4f07887b5fd28ba91505444e3a0c6a0d2f52a9 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:12:59 +0100 Subject: [PATCH 09/49] Explained what the error messages were saying and the line where they occurred --- Sprint-2/1-key-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 95a49d5dc3..1907744d54 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -14,7 +14,7 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> write your explanation here +// =============> write your explanation /* the first error SyntaxError pointed at line 9 as to where the error occurred and explained that the identifier-decimalNumber has already been declared. The second error ReferenceError pointed at line 15 as to where the error occurred and explained that the identifier-decimalNumber is not defined in the global scope. */ /* /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/1.js:9 const decimalNumber = 0.5; ^ From 2bca2a93309f22fe1b4e1af8947a82afaff8a364 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:15:16 +0100 Subject: [PATCH 10/49] commented out the original program so I can write a new working code --- Sprint-2/1-key-errors/1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 1907744d54..1baba2e2a3 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -5,14 +5,14 @@ // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { +/*function convertToPercentage(decimalNumber) { decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(decimalNumber); +console.log(decimalNumber); */ // =============> write your explanation /* the first error SyntaxError pointed at line 9 as to where the error occurred and explained that the identifier-decimalNumber has already been declared. The second error ReferenceError pointed at line 15 as to where the error occurred and explained that the identifier-decimalNumber is not defined in the global scope. */ /* /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/1.js:9 From 83f2a2adf870ab245379c51b676f9cb4f3d97495 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:29:16 +0100 Subject: [PATCH 11/49] removed the Variable reassignment to allow any decimal arguement to be passed during function call --- Sprint-2/1-key-errors/1.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 1baba2e2a3..fc09e548b3 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -28,3 +28,11 @@ ReferenceError: decimalNumber is not defined*/ // Finally, correct the code to fix the problem // =============> write your new code here +function convertToPercentage(decimalNumber) { + // removed the variable reassignment so that function call will work with any argument passed to it. + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} + +console.log(convertToPercentage(0.75)); From 56258790c1a0fd0181375ee07a9ab983c9e762d7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:48:51 +0100 Subject: [PATCH 12/49] commented out the original code --- Sprint-2/1-key-errors/2.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..a75d04696c 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -1,17 +1,17 @@ -// Predict and explain first BEFORE you run any code... +// Predict and explain first BEFORE you run any code...we are going to get a SyntaxError because the function parameter is a number and not a variable name. The function parameter should be a variable name that can be used inside the function body. // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> write your prediction of the error here // SyntaxError: Unexpected number. -function square(3) { +/*function square(3) { return num * num; -} +}*/ -// =============> write the error message here +// =============> write the error message here /* /home/tobi/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/2.js:8 function square(3) { SyntaxError: Unexpected number*/ -// =============> explain this error message here +// =============> explain this error message here/* this error is saying that something is wrong with the function parameter because it is a number and not a variable name. The function parameter should be a variable name that can be used inside the function body. the SyntaxError denote that the rule is violated, and pointed out that the number is unexpected at line 8 */ // Finally, correct the code to fix the problem From 5e1b919c6074b6a81b696161f8b391579c485394 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 17:51:06 +0100 Subject: [PATCH 13/49] wrote a new code that worked --- Sprint-2/1-key-errors/2.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index a75d04696c..2cbbc827db 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -16,5 +16,9 @@ // Finally, correct the code to fix the problem // =============> write your new code here +function square(num) { + return num*num; +} +square(); From 5cb01c72a3742cab5add9afc86ce5e04b0d4dc13 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:12:15 +0100 Subject: [PATCH 14/49] gave my prediction of what the two console .log will print to the screen --- Sprint-2/2-mandatory-debug/0.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b417..d7ce266b09 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,7 +1,6 @@ // Predict and explain first... -// =============> write your prediction here - +// =============> write your prediction here// The code will print 320 and undefine secondly. function multiply(a, b) { console.log(a * b); } From c6e39912eb59684afa2155329a911d6f3f0da68d Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:18:15 +0100 Subject: [PATCH 15/49] gave the explanation as to why the fist console.log inside the function printed a value and the one ouside that called the fuction using template literal produce undefine --- Sprint-2/2-mandatory-debug/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index d7ce266b09..021d618421 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -7,7 +7,7 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> write your explanation here. /* The function multiply is called inside the console.log statement, but it does not return any value. Instead, it only logs the result of multiplying a and b to the console. Therefore, when the console.log statement is executed, it will print "The result of multiplying 10 and 32 is undefined" because the multiply function does not return anything. The first console.log inside the multiply function will print 320 to the console, but the second console.log will print undefined. */ // Finally, correct the code to fix the problem // =============> write your new code here From 637daa2cdfe6536c089196d3539640a24775c305 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:20:13 +0100 Subject: [PATCH 16/49] commented out the original code to allow re-writing a new one --- Sprint-2/2-mandatory-debug/0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 021d618421..5b1115d416 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,11 +1,11 @@ // Predict and explain first... // =============> write your prediction here// The code will print 320 and undefine secondly. -function multiply(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 function multiply is called inside the console.log statement, but it does not return any value. Instead, it only logs the result of multiplying a and b to the console. Therefore, when the console.log statement is executed, it will print "The result of multiplying 10 and 32 is undefined" because the multiply function does not return anything. The first console.log inside the multiply function will print 320 to the console, but the second console.log will print undefined. */ From 31c2ebd9920d12e6ea2284cac11d2c26734b669c Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:23:36 +0100 Subject: [PATCH 17/49] wrote a new code that did not print undefined as a vaule --- Sprint-2/2-mandatory-debug/0.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 5b1115d416..b0628787a2 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -11,3 +11,9 @@ 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 dee2a91b9ccf6151480adfa0cd20e3b853644e8f Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:36:01 +0100 Subject: [PATCH 18/49] gave my prediction that the function when called will give undefined --- Sprint-2/2-mandatory-debug/1.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..b53d267c56 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,6 +1,5 @@ // Predict and explain first... -// =============> write your prediction here - +// =============> write your prediction here // will print undefined. function sum(a, b) { return; a + b; From 5d0b10b8bbc1897cac9c92fefce344248283c38d Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:37:06 +0100 Subject: [PATCH 19/49] gave an explanation as to why the console.log method produced undefined --- Sprint-2/2-mandatory-debug/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index b53d267c56..c24f607ef1 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -7,6 +7,7 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> write your explanation here.// The code will print undefined because the function sum does not return any value. Instead, it has a return statement with no value, which means it will return undefined by default. The second line of the function, a + b, is never executed because the return statement ends the function execution before it can be reached. + // Finally, correct the code to fix the problem // =============> write your new code here From 8e9bc16c841fc3bf0f8980caf1c056d58966a3db Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:40:11 +0100 Subject: [PATCH 20/49] added more context to the explantion -how semicolon ended the return statement before the expression a +b could be reached --- Sprint-2/2-mandatory-debug/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index c24f607ef1..8ae00c7c7c 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -7,7 +7,7 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here.// The code will print undefined because the function sum does not return any value. Instead, it has a return statement with no value, which means it will return undefined by default. The second line of the function, a + b, is never executed because the return statement ends the function execution before it can be reached. +// =============> write your explanation here.// The code will print undefined because the function sum does not return any value. Instead, it has a return statement with no value, because the semicolon ended the return statement which means it will return undefined by default. The second line of the function, a + b, is never executed because the return statement ends the function execution before it can be reached. // Finally, correct the code to fix the problem // =============> write your new code here From 1e18211e3350342f1b48e95c5c97cecaf966ab1c Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:41:36 +0100 Subject: [PATCH 21/49] commented out the original code to aid re-writing a new one --- Sprint-2/2-mandatory-debug/1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 8ae00c7c7c..f4c4c78006 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,11 +1,11 @@ // Predict and explain first... // =============> write your prediction here // will print undefined. -function sum(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.// The code will print undefined because the function sum does not return any value. Instead, it has a return statement with no value, because the semicolon ended the return statement which means it will return undefined by default. The second line of the function, a + b, is never executed because the return statement ends the function execution before it can be reached. From 3ced51b7cc7a9ecfb645b02d2890cf022f607b8c Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:42:49 +0100 Subject: [PATCH 22/49] wrote a new code that works --- Sprint-2/2-mandatory-debug/1.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index f4c4c78006..3f6cc60996 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -11,3 +11,8 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);*/ // 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 92b372e06eca817cecc66cb764c758d7d754732e Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 18:58:58 +0100 Subject: [PATCH 23/49] Wrote my prediction with an explanations --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc35..099a6e0629 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,7 +1,7 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> Write your prediction here./* The output will be 3 because the function getLastDigit is not using the argument passed to it, instead it is using the global variable num which is set to 103. Therefore, the last digit of 103 is 3 and that is what will be printed for all three console.log statements.*/ const num = 103; From d6f096cb55b3a87c87bdd72f6a35305102ed53e2 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 19:01:52 +0100 Subject: [PATCH 24/49] Wrote the ouput when the code was ran and compare them with my predictions --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 099a6e0629..fd2033aef1 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -14,7 +14,7 @@ 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 +// =============> write the output here// The out put is 3 for the three console.log calls as predicted // Explain why the output is the way it is // =============> write your explanation here // Finally, correct the code to fix the problem From 14b44dc8b5085d601a8b39f0ecffc1ed3cd55c3e Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 19:04:40 +0100 Subject: [PATCH 25/49] Explained why the output 3 for the three different Arguements --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index fd2033aef1..17e8923619 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -16,7 +16,7 @@ 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 out put is 3 for the three console.log calls as predicted // Explain why the output is the way it is -// =============> write your explanation here +// =============> write your explanation here. /* The reason is because the function getLastDigit is not using the argument passed to it, instead it is using the global variable num which is set to 103. Therefore, the last digit of 103 is 3 and that is what will be printed for all three console.log statements.*/ // Finally, correct the code to fix the problem // =============> write your new code here From b98f6b1ed7bb4645f5914f11d17cdf347434a756 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 19:06:35 +0100 Subject: [PATCH 26/49] commented out the original code to allow for re-write of new code --- Sprint-2/2-mandatory-debug/2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 17e8923619..26f20c896e 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -3,7 +3,7 @@ // Predict the output of the following code: // =============> Write your prediction here./* The output will be 3 because the function getLastDigit is not using the argument passed to it, instead it is using the global variable num which is set to 103. Therefore, the last digit of 103 is 3 and that is what will be printed for all three console.log statements.*/ -const num = 103; +/*const num = 103; function getLastDigit() { return num.toString().slice(-1); @@ -11,7 +11,7 @@ function getLastDigit() { 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 806 is ${getLastDigit(806)}`);*/ // Now run the code and compare the output to your prediction // =============> write the output here// The out put is 3 for the three console.log calls as predicted From 609ccf649bdd54ab3ed231fe4f30e78e211d97cc Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 19:10:56 +0100 Subject: [PATCH 27/49] Wrote the new code to fix the scope issue with the global variable --- Sprint-2/2-mandatory-debug/2.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 26f20c896e..c7ccfbe262 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -20,5 +20,15 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);*/ // Finally, correct the code to fix the problem // =============> write your new code here + + +function getLastDigit(num) { + 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)}`); + // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 6c7e4835a39e1019d1dbaa4fd656c1027e9474bf Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 26 Jun 2026 19:14:18 +0100 Subject: [PATCH 28/49] Explanation was given as to why the code did not work and how it was fixed --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index c7ccfbe262..431989efed 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -31,4 +31,4 @@ 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 +// Explain why getLastDigit is not working properly - correct the problem// The variable num was a global variable , that is is why it was not working becasue it was declared outside of the function and was fixed by declaring it inside the function as a parameter . From 47a68fdb396d556811ee3309dcd648a88ab590c0 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 06:14:03 +0100 Subject: [PATCH 29/49] Added the return statment to the function's body --- Sprint-2/3-mandatory-implement/1-bmi.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1b..fd6eb2eaf4 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,5 +15,6 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { + return`The BMI of someone with a weight of ${weight}kg and a height of ${height}m is ${(weight / (height * height)).toFixed(1)}`; // return the BMI of someone based off their weight and height } \ No newline at end of file From 4290aae10716f87e65cf6b3a22b7cfb695b5f419 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 06:16:36 +0100 Subject: [PATCH 30/49] the function was called and console to the screen with the two arguement and it worked --- Sprint-2/3-mandatory-implement/1-bmi.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index fd6eb2eaf4..7d7491483f 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -17,4 +17,5 @@ function calculateBMI(weight, height) { return`The BMI of someone with a weight of ${weight}kg and a height of ${height}m is ${(weight / (height * height)).toFixed(1)}`; // return the BMI of someone based off their weight and height -} \ No newline at end of file +} +console.log(calculateBMI(70, 1.73)); // should return 23.4 \ No newline at end of file From 251d837b130afb4d9304a57ce9e7fff03fe74ac7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 06:34:40 +0100 Subject: [PATCH 31/49] wrote the function with an apprioprate name --- Sprint-2/3-mandatory-implement/2-cases.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad9..c7cf3931c9 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,8 @@ // 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 convertToUpperSnakeCase(inputString) { + return inputString.replace(/\s+/g,'_').toUpperCase(); +} +console.log(convertToUpperSnakeCase("there is fire on the montain")); \ No newline at end of file From 760b0f9e8db769110a0f465e8c8f09e774377ae3 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 07:05:04 +0100 Subject: [PATCH 32/49] used the programm in Sprint-1 and turn it into a resuable code by implementing a function with apprioprate name --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a703..fc13d69975 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,24 @@ // 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}`); +} +console.log(toPounds("30p")); \ No newline at end of file From 7ed11f34b90bd75ef72b0f5ddc69096a4caa7483 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 15:40:12 +0100 Subject: [PATCH 33/49] Answered how many number of times the pad was called --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 17127bc01e..519c66ca2a 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -21,7 +21,7 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> write your answer here// three times // Call formatTimeDisplay with an input of 61, now answer the following: From 4f030b8d2b33605fb7cd47f10e3771d101b31bb9 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 16:19:38 +0100 Subject: [PATCH 34/49] answere the question on the value assigned to pad when it's called for the first time --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 519c66ca2a..9c838ffd1f 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -26,7 +26,7 @@ function formatTimeDisplay(seconds) { // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> write your answer here 0. // c) What is the return value of pad is called for the first time? // =============> write your answer here From 356bd08f222e402127a37c3a71faf6a3dbf9cb64 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 16:22:17 +0100 Subject: [PATCH 35/49] add comment sign to my earlier answer --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 9c838ffd1f..b83d9cd878 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -26,7 +26,7 @@ function formatTimeDisplay(seconds) { // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here 0. +// =============> write your answer here //0. // c) What is the return value of pad is called for the first time? // =============> write your answer here From 7fdc864c827ef8ff5b2d2a71a82267cff9f23f18 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 16:26:09 +0100 Subject: [PATCH 36/49] answere question on what is the return value of pad when called for the first time --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index b83d9cd878..9cd614f733 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -29,7 +29,7 @@ function formatTimeDisplay(seconds) { // =============> write your answer here //0. // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// =============> write your answer here// "00" // 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 cac50d07fcaf69ef89b49baaac01b72bfb05d6cd Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 16:29:59 +0100 Subject: [PATCH 37/49] Answered the question of assign value to num when pad was called the last time --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 9cd614f733..ebcfe9505c 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -32,7 +32,7 @@ function formatTimeDisplay(seconds) { // =============> write your answer here// "00" // 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 +// =============> write your answer here// 1 // 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 65d9d7fa2c8e578628077230fe50f6e21296fa57 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 27 Jun 2026 16:31:48 +0100 Subject: [PATCH 38/49] Answered question on the returned value to pad when its called the last time --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index ebcfe9505c..e82c6d398c 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -35,4 +35,4 @@ function formatTimeDisplay(seconds) { // =============> write your answer here// 1 // 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 +// =============> write your answer here// "01" From 5ec6dee5a683b59ca9fefa8650dbeee379c6753c Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 20:24:22 +0100 Subject: [PATCH 39/49] reset the file to it's orinal state --- Sprint-2/5-stretch-extend/format-time.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b8..b8fa40741b 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -23,3 +23,5 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); + + From cae676c19923dfbef695139734115c398f743112 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 20:43:26 +0100 Subject: [PATCH 40/49] wrote an Assertion to test Mid-day , which failed --- Sprint-2/5-stretch-extend/format-time.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index b8fa40741b..3bc5e3756c 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -23,5 +23,12 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); +// testing for noon @ "12:00" +const currentOutput3 = formatAs12HourClock("12:00"); +const targetOutput3 = "12:00 pm"; +console.assert( + currentOutput3 === targetOutput3, + `current output: ${currentOutput3}, target output: ${targetOutput3}` +); From ee0dcaf43be9239041ba2e4b7a20d40a6beccff7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 20:50:53 +0100 Subject: [PATCH 41/49] Wrote a code to fix the assertion --- Sprint-2/5-stretch-extend/format-time.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 3bc5e3756c..f6d5edbd76 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -7,6 +7,9 @@ function formatAs12HourClock(time) { if (hours > 12) { return `${hours - 12}:00 pm`; } + if (hours===12){ + return `${hours}:00 pm`; +} return `${time} am`; } From 0241153a245afd6de0788efad97cd5df50570387 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 21:01:31 +0100 Subject: [PATCH 42/49] wrote an assertion to test for Midnight , and it failed as it current output '00:00am' instead of '12:00am' --- Sprint-2/5-stretch-extend/format-time.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index f6d5edbd76..74c7a8f830 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -33,5 +33,11 @@ console.assert( currentOutput3 === targetOutput3, `current output: ${currentOutput3}, target output: ${targetOutput3}` ); - +//Testing for Midnight +const currentOutput4 = formatAs12HourClock("00:00"); +const targetOutput4 = "12:00 am"; +console.assert( +currentOutput4 === targetOutput4, +`current output: ${currentOutput4}, targetOutput: ${targetOutput4}` +); From e3bb58b50276ae55286b51d564dc66c06df7ef5a Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 21:25:15 +0100 Subject: [PATCH 43/49] wrote the code and corrected the variable namet 'targetOutput to target output' for the assertion to work --- Sprint-2/5-stretch-extend/format-time.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 74c7a8f830..9c985f71f7 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -10,6 +10,9 @@ function formatAs12HourClock(time) { if (hours===12){ return `${hours}:00 pm`; } + if (hours===0){ + return `${12}:00 am `; + } return `${time} am`; } @@ -38,6 +41,6 @@ const currentOutput4 = formatAs12HourClock("00:00"); const targetOutput4 = "12:00 am"; console.assert( currentOutput4 === targetOutput4, -`current output: ${currentOutput4}, targetOutput: ${targetOutput4}` +`current output: ${currentOutput4}, target output: ${targetOutput4}` ); From 93705d48a9594d9d578b7277ee5008b28bf43a37 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 21:36:54 +0100 Subject: [PATCH 44/49] removed the white space after the am in the current ouput for the midnight code in the function body as noticed that assertion still fails --- Sprint-2/5-stretch-extend/format-time.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 9c985f71f7..d330ddecf4 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -11,7 +11,7 @@ function formatAs12HourClock(time) { return `${hours}:00 pm`; } if (hours===0){ - return `${12}:00 am `; + return `${12}:00 am`; } return `${time} am`; } @@ -44,3 +44,10 @@ currentOutput4 === targetOutput4, `current output: ${currentOutput4}, target output: ${targetOutput4}` ); +const currentOutput5 = formatAs12HourClock("13:00"); +const targetOutput5 = "01:00 pm"; +console.assert( + currentOutput5 === targetOutput5, + `current output: ${currentOutput5}, target output: ${targetOutput5}` +); + From 5ac78f951f2784ae26eacaca500e411baf10e668 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 21:41:08 +0100 Subject: [PATCH 45/49] adding comment to explain the assetion already witten to test when there is no leading zeros --- Sprint-2/5-stretch-extend/format-time.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index d330ddecf4..43e1853358 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -43,6 +43,7 @@ console.assert( currentOutput4 === targetOutput4, `current output: ${currentOutput4}, target output: ${targetOutput4}` ); +// Testing for leading zeros const currentOutput5 = formatAs12HourClock("13:00"); const targetOutput5 = "01:00 pm"; From d8396ef07b5069b05f4e6718103cca3d8e402bd2 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 28 Jun 2026 21:48:26 +0100 Subject: [PATCH 46/49] fixed the code with String method and padStart method --- Sprint-2/5-stretch-extend/format-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 43e1853358..48f20d7150 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -5,7 +5,7 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${String(hours - 12).padStart(2,"0")}:00 pm`; } if (hours===12){ return `${hours}:00 pm`; From 5e3b5f6a14576a49936b54077b9f50123fe1f9bb Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 5 Jul 2026 02:47:24 +0100 Subject: [PATCH 47/49] updated the code to only return number and not string --- Sprint-2/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 7d7491483f..bae685f389 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,7 +15,7 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return`The BMI of someone with a weight of ${weight}kg and a height of ${height}m is ${(weight / (height * height)).toFixed(1)}`; + return` $ ${(weight / (height * height)).toFixed(1)}`; // return the BMI of someone based off their weight and height } console.log(calculateBMI(70, 1.73)); // should return 23.4 \ No newline at end of file From 65daf85b94afa4ce9d12a743a9e9a648000029be Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 5 Jul 2026 02:55:56 +0100 Subject: [PATCH 48/49] removed the template string to make the return value a number instead of a string --- Sprint-2/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index bae685f389..0beb2915e2 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,7 +15,7 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return` $ ${(weight / (height * height)).toFixed(1)}`; + return (weight / (height * height)).toFixed(1); // return the BMI of someone based off their weight and height } console.log(calculateBMI(70, 1.73)); // should return 23.4 \ No newline at end of file From d58ef31628cc0542c82f0ae1028868b0713ea0dd Mon Sep 17 00:00:00 2001 From: Tobias Date: Sun, 5 Jul 2026 03:08:54 +0100 Subject: [PATCH 49/49] updated the template string with just number --- Sprint-2/5-stretch-extend/format-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 48f20d7150..631e8f0ace 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -11,7 +11,7 @@ function formatAs12HourClock(time) { return `${hours}:00 pm`; } if (hours===0){ - return `${12}:00 am`; + return "12:00 am"; } return `${time} am`; }