From 2dc31c33dc1bfbe1f6988fda082c42b8c90dc47a Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Wed, 25 Feb 2026 11:00:05 +0000 Subject: [PATCH 1/7] I have dome sprint2 for structuring data module --- Sprint-1/1-key-exercises/1-count.js | 1 + Sprint-2/1-key-errors/0.js | 14 ++++----- Sprint-2/1-key-errors/1.js | 13 +++----- Sprint-2/1-key-errors/2.js | 23 +++++++++----- Sprint-2/2-mandatory-debug/0.js | 22 ++++++++++++- Sprint-2/2-mandatory-debug/1.js | 20 ++++++++++++ Sprint-2/2-mandatory-debug/2.js | 31 +++++++++++++++++++ Sprint-2/3-mandatory-implement/1-bmi.js | 5 ++- Sprint-2/3-mandatory-implement/2-cases.js | 16 ++++++++++ Sprint-2/3-mandatory-implement/3-to-pounds.js | 29 +++++++++++++++++ Sprint-2/4-mandatory-interpret/time-format.js | 6 ++++ Sprint-2/5-stretch-extend/format-time.js | 24 ++++++++++++++ 12 files changed, 179 insertions(+), 25 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..20ac1f4e7 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,4 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing +// updates the value of the variable count by adding 1 \ No newline at end of file diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..81874537e 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,13 +1,13 @@ // Predict and explain first... -// =============> write your prediction here +// Missing backticks for template string template strings need to use backticks `, but here ${} is used without them -// call the function capitalise with a string input +// call the function capitalise with a string input (error) // interpret the error message and figure out why an error is occurring +// ${} must be inside backticks and str is being redeclared (it is already the function parameter) -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} // =============> write your explanation here -// =============> write your new code here +// =============> This function takes a string and returns a new string with the first letter in capital +function capitalise(str) { + return `${str[0].toUpperCase()}${str.slice(1)}`; +} diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..178ca218e 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,20 +1,15 @@ // Predict and explain first... -// Why will an error occur when this program runs? -// =============> write your prediction here +// decimalNumber is already declared as a function parameter. and name variable the same // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; - return percentage; } -console.log(decimalNumber); - -// =============> write your explanation here +console.log(convertToPercentage(0.5)); -// Finally, correct the code to fix the problem -// =============> write your new code here +// creates a function named convertToPercentage +// The function returns the percentage string.SS diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..edebea38c 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -3,18 +3,27 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// Error because the variable 'num' is not defined when we try to call the function. +// The function expects +// a parameter but we're not passing any argument when calling it. -function square(3) { +function square(num) { return num * num; } -// =============> write the error message here +// The function will return NaN  (Not a Number) +// this doesn't throw an error, but returns NaN  because: +// - num is undefined (no argument passed) +// - undefined * undefined = NaN  -// =============> explain this error message here +// When square() is called without an argument, the parameter 'num' has +// // the value 'undefined'. When you multiply undefined * undefined, +// // JavaScript returns NaN (Not a Number) instead of throwing an error.  -// Finally, correct the code to fix the problem - -// =============> write your new code here +function square(num) + { + return num * num; + } + console.log(square(5)); // Output: 25 console.log(square(10));  diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..7d181fee1 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,6 +1,10 @@ // Predict and explain first... -// =============> write your prediction here +//The output is 320 +//no define the reult of multiplying 10 and 32 +// This is because the multiply function uses console.log() instead of return. +// The function will print 320 to the console, but then will show +// "undefined" because the function doesn't return a value. function multiply(a, b) { console.log(a * b); @@ -10,5 +14,21 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here +//The multiply() function calculates a * b (which is 320) and prints it +// using console.log(). +//console.log() doesn't return a value just output of console +// it only displays output to the console. +// +// there is no return statement, it returns 'undefined'. +// the function: +// 1. Prints "320" to the console +// 2. Returns undefined +// "The result of multiplying 10 and 32 is undefined" + // Finally, correct the code to fix the problem // =============> write your new code here + +function multiply(a, b) { + return a * b; // use return not console +} +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); \ No newline at end of file diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..2a56546f8 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,6 +1,12 @@ // Predict and explain first... // =============> write your prediction here +//The output will be: +// "The sum of 10 and 32 is not defined because the return statement without a value. +// The line "a + b;" after return will not executed +// return undefined. The code after return is unreachable. + + function sum(a, b) { return; a + b; @@ -9,5 +15,19 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +// a + b; ← This line will not executes (unreachable code) +// So the function effectively becomes: +// function sum(a, b) { +// return undefined; +// a + b; // not execute +// } +// The return statement immediately exits the function and returns undefined. +// Any code after a return statement is "unreachable" and not execute. +// result is the sum of 10 and 32 is undefined" // 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)}`); diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..1fe93e44a 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -2,6 +2,13 @@ // Predict the output of the following code: // =============> Write your prediction here +//The output will be: +// The last digit of 42 is 3 +// The last digit of 105 is 3 +// The last digit of 806 is 3 +// +// All outputs show "3" because the function not taking the parameter +// passe value to 'num' (which is 103), so it returns the last digit of 103, which is 3. const num = 103; @@ -15,10 +22,34 @@ 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 +// The function getLastDigit() has TWO problems: +// The function definition doesn't have a parameter, +// it can't receive the values (42, 105, 806) added to it. +//inside the function, it uses the global constant +// 'num' (which is 103) instead of using the parameter +//getLastDigit(42) call function not taking 42 +// num (103) converts to "103" +// -slice(-1) gets the last character "3" +// returns "3" // Finally, correct the code to fix the problem // =============> write your new code here +const num1 = 103; +function getLastDigit(number) { // Added parameter 'number' + return number.toString().slice(-1); // Use 'number' instead of 'num' +} +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 +//The function has no parameter when call getLastDigit(42), +// the number 42 is passed but storage variable to save it. +// The function can't use it because it doesn't have a parameter to receive it. diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1..614e3ecba 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -16,4 +16,7 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height -} \ No newline at end of file + return Math.round((weight / (height * height)) * 10) / 10; +} + +console.log(calculateBMI(70, 1.73)); diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..cb85fac14 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,19 @@ // 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(str) { + // Step 1: Replace all spaces with _ + const withUnderscores = str.replace(/ /g, '_'); + + // Step 2: Convert to uppercase + const upperCase = withUnderscores.toUpperCase(); + + return upperCase; +} + +// Test +console.log(toUpperSnakeCase("hello there")); // "HELLO_THERE" +console.log(toUpperSnakeCase("lord of the rings")); // "LORD_OF_THE_RINGS" +console.log(toUpperSnakeCase("the quick brown fox")); // "THE_QUICK_BROWN_FOX" +console.log(toUpperSnakeCase("code your future")); // "CODE_YOUR_FUTURE" \ No newline at end of file diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..bac9f3e6b 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,32 @@ // 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 to convert pence string to pounds format +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}`; +} + +// Test the function with inputs +console.log(toPounds("399p")); // "£3.99" +console.log(toPounds("50p")); // "£0.50" +console.log(toPounds("5p")); // "£0.05" +console.log(toPounds("1p")); // "£0.01" +console.log(toPounds("99p")); // "£0.99" +console.log(toPounds("100p")); // "£1.00" +console.log(toPounds("1250p")); // "£12.50" +console.log(toPounds("10000p")); // "£100.00" +console.log(toPounds("199p")); // "£1.99" +console.log(toPounds("2550p")); // "£25.50" diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8..cb66b2ce8 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -19,16 +19,22 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// 3 times // 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 // c) What is the return value of pad is called for the first time? // =============> 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 +// 1 // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer // =============> write your answer here + +// "01" diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b..1984fbea4 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -23,3 +23,27 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); + +// Test of existing fuction +console.log("=== TESTING BUGGY FUNCTION ==="); +console.log(formatAs12HourClock("00:00"), "→ Expected: 12:00 am ❌"); // Bug: midnight +console.log(formatAs12HourClock("12:00"), "→ Expected: 12:00 pm ❌"); // Bug: noon +console.log(formatAs12HourClock("14:30"), "→ Expected: 02:30 pm ❌"); // Bug: minutes lost +console.log(formatAs12HourClock("08:15"), "→ Expected: 08:15 am ❌"); // Bug: minutes lost +console.log(formatAs12HourClock("23:59"), "→ Expected: 11:59 pm ❌"); // Bug: minutes lost + + +// Fixed function + +function formatAs12HourClockFixed(time) { + const hours = Number(time.slice(0, 2)); + const minutes = time.slice(3, 5); + + if (hours === 0) return `12:${minutes} am`; // Midnight + if (hours === 12) return `12:${minutes} pm`; // Noon + if (hours > 12) { + const h = (hours - 12).toString().padStart(2, "0"); + return `${h}:${minutes} pm`; + } + return `${time.slice(0, 5)} am`; +} \ No newline at end of file From cb70a2187c240829038722076dd5e88d25f1e428 Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Wed, 25 Feb 2026 11:26:17 +0000 Subject: [PATCH 2/7] I have made the correction --- Sprint-2/5-stretch-extend/format-time.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 1984fbea4..e6ddf5b6d 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -46,4 +46,5 @@ function formatAs12HourClockFixed(time) { return `${h}:${minutes} pm`; } return `${time.slice(0, 5)} am`; -} \ No newline at end of file +} + From d0df0811e59f436076e88a9542420017f8e30e0b Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Wed, 25 Feb 2026 16:23:21 +0000 Subject: [PATCH 3/7] I made changes --- 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 e6ddf5b6d..4de6efeaa 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -33,7 +33,7 @@ console.log(formatAs12HourClock("08:15"), "→ Expected: 08:15 am ❌"); // Bug: console.log(formatAs12HourClock("23:59"), "→ Expected: 11:59 pm ❌"); // Bug: minutes lost -// Fixed function +// Fixed function to get result function formatAs12HourClockFixed(time) { const hours = Number(time.slice(0, 2)); From 1de86ca6ced8cca9a2cd0cb8504e68e1208dde06 Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Wed, 25 Feb 2026 16:30:04 +0000 Subject: [PATCH 4/7] changes --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- Sprint-2/5-stretch-extend/format-time.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index cb66b2ce8..acd6dc3bf 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -11,7 +11,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } -// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit +// You will need to play computer with this example - use the Python Visual https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions // Questions diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 4de6efeaa..1569c5634 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -24,7 +24,7 @@ console.assert( `current output: ${currentOutput2}, target output: ${targetOutput2}` ); -// Test of existing fuction +// Test of existing console.log("=== TESTING BUGGY FUNCTION ==="); console.log(formatAs12HourClock("00:00"), "→ Expected: 12:00 am ❌"); // Bug: midnight console.log(formatAs12HourClock("12:00"), "→ Expected: 12:00 pm ❌"); // Bug: noon From 2706654b0f1d33e1830e21770c24e9cdd40f5fcc Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Wed, 25 Feb 2026 16:47:25 +0000 Subject: [PATCH 5/7] changes --- Sprint-2/4-mandatory-interpret/time-format.js | 2 +- Sprint-2/5-stretch-extend/format-time.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index cb66b2ce8..acd6dc3bf 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -11,7 +11,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } -// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit +// You will need to play computer with this example - use the Python Visual https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions // Questions diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 1984fbea4..bd0ba32b0 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -24,7 +24,7 @@ console.assert( `current output: ${currentOutput2}, target output: ${targetOutput2}` ); -// Test of existing fuction +// Test of existing function console.log("=== TESTING BUGGY FUNCTION ==="); console.log(formatAs12HourClock("00:00"), "→ Expected: 12:00 am ❌"); // Bug: midnight console.log(formatAs12HourClock("12:00"), "→ Expected: 12:00 pm ❌"); // Bug: noon From da626b2fb7eb7e4eff9847e60dbbb9fbde0c9772 Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Wed, 25 Feb 2026 17:08:52 +0000 Subject: [PATCH 6/7] I made right changes --- Sprint-1/1-key-exercises/1-count.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 20ac1f4e7..117bcb2b6 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,4 +4,3 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing -// updates the value of the variable count by adding 1 \ No newline at end of file From 632f5bea330c293a36ec16b164eb7f5e0167845b Mon Sep 17 00:00:00 2001 From: Alrzini2025 Date: Thu, 26 Feb 2026 09:17:21 +0000 Subject: [PATCH 7/7] I made changes based on review --- Sprint-2/1-key-errors/0.js | 33 +++++++++++++++++------- Sprint-2/5-stretch-extend/format-time.js | 12 +++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 81874537e..929bdf395 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,13 +1,28 @@ // Predict and explain first... -// Missing backticks for template string template strings need to use backticks `, but here ${} is used without them +/// This code will error before it runs. 'str' has already been declared" +// +// This happens because: +// 1. 'str' is already declared as a function parameter +// 2. Inside the function, we try to declare 'str' again using 'let' + +// original code +//function capitalise(str) { + //let str = `${str[0].toUpperCase()}${str.slice(1)}`; +//return str; +//} -// call the function capitalise with a string input (error) -// interpret the error message and figure out why an error is occurring -// ${} must be inside backticks and str is being redeclared (it is already the function parameter) +// write your explanation here + //When you write: function capitalize(str) +// - 'str' is already declared as a parameter +//Then inside the function: let str = ... +// - This tries to declare 'str' again - -// =============> write your explanation here -// =============> This function takes a string and returns a new string with the first letter in capital +// new code function capitalise(str) { - return `${str[0].toUpperCase()}${str.slice(1)}`; -} + let capitalised = `${str[0].toUpperCase()}${str.slice(1)}`; + return capitalised; +} + +console.log(capitalise("hello")); // "Hello" + + diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index bc9f6b6b6..80ee66504 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -49,3 +49,15 @@ function formatAs12HourClockFixed(time) { return `${time.slice(0, 5)} am`; } +console.log("=== Test for fixed function ===\n"); + +console.log(formatAs12HourClockFixed("00:00"), "→ Expected: 12:00 am"); +console.log(formatAs12HourClockFixed("00:30"), "→ Expected: 12:30 am"); +console.log(formatAs12HourClockFixed("01:00"), "→ Expected: 01:00 am"); +console.log(formatAs12HourClockFixed("08:15"), "→ Expected: 08:15 am"); +console.log(formatAs12HourClockFixed("11:59"), "→ Expected: 11:59 am"); +console.log(formatAs12HourClockFixed("12:00"), "→ Expected: 12:00 pm"); +console.log(formatAs12HourClockFixed("12:30"), "→ Expected: 12:30 pm"); +console.log(formatAs12HourClockFixed("13:00"), "→ Expected: 01:00 pm"); +console.log(formatAs12HourClockFixed("14:45"), "→ Expected: 02:45 pm"); +console.log(formatAs12HourClockFixed("23:59"), "→ Expected: 11:59 pm");