From c85f975b9b880e01aee77147d89b720c7fdd0004 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 16:16:47 +0100 Subject: [PATCH 01/19] complete ex 0.js --- Sprint-3/1-key-errors/0.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..68feb4e3a 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,21 @@ // Predict and explain first... -// =============> write your prediction here +// =============>// I predict JavaScript will give a SyntaxError because str is declared twice in the function. // 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; } - -// =============> write your explanation here +capitalise("hello");*/ +/* =============> The error happens because str is already the function's parameter. + let str tries to use the same name again, so JavaScript gives a SyntaxError. + The function stops before it can run. */ // =============> write your new code here +function capitalise(str) { + const result = `${str[0].toUpperCase()}${str.slice(1)}`; + return result; +} +capitalise("hello"); +console.log(capitalise("hello")); From e071e69572b1b306525f79ed273312fecf7f8f86 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 16:41:33 +0100 Subject: [PATCH 02/19] complete ex 1.js --- Sprint-3/1-key-errors/1.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..3583921d0 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,20 +1,29 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============>// I predict a SyntaxError because decimalNumber is declared as a parameter and then declared again with const. // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { +/*function convertToPercentage(decimalNumber) { const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(decimalNumber); +console.log(decimalNumber);*/ -// =============> write your explanation here +/* =============> decimalNumber is already the function parameter. + const decimalNumber tries to declare the same name again inside the function, + so JavaScript gives a SyntaxError. */ // 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)); From 6570ced6853ec74108fe7fbd2cfdbb362933ca89 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 16:50:05 +0100 Subject: [PATCH 03/19] write prediction for 2.js --- 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..fedc9d965 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -3,7 +3,7 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> // I predict a SyntaxError because 3 is a number, but a function parameter needs to be a name. function square(3) { return num * num; From 001939bf3f0f0e9ab45fd7d8f8bedbd0c879d400 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 17:14:51 +0100 Subject: [PATCH 04/19] complete ex 2.js --- Sprint-3/1-key-errors/2.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index fedc9d965..042368fa6 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,21 @@ - // Predict and explain first BEFORE you run any code... // this function should square any number but instead we're going to get an error // =============> // I predict a SyntaxError because 3 is a number, but a function parameter needs to be a name. -function square(3) { +/*function square(3) { return num * num; } +*/ +// =============> SyntaxError: Unexpected number -// =============> write the error message here - -// =============> explain this error message here +// =============> The error happens because 3 is not a name. A parameter needs a name, like num. // Finally, correct the code to fix the problem // =============> write your new code here - - +function square(num) { + return num * num; +} +console.log(square(3)); From 9650964878922774c54c4836c9ab20e788f41dd0 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 17:28:12 +0100 Subject: [PATCH 05/19] complete ex 0.js --- Sprint-3/2-mandatory-debug/0.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..1661caf95 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,18 @@ // Predict and explain first... -// =============> write your prediction here +// =============> I couldn't predict until I run the code -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)}`); - -// =============> write your explanation here +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);*/ +/* =============> The Terminal gives an answer of 320 but also says "The result of multiplying 10 and 32 is undefined" +which makes me think that the function has no return so it gives back undefined.*/ // 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 af75a19fd0f49a6aca155f9193c662a2f43793ac Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 17:33:51 +0100 Subject: [PATCH 06/19] complete ex 1.js --- Sprint-3/2-mandatory-debug/1.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..0d7d597b5 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,19 @@ // Predict and explain first... -// =============> write your prediction here +// =============> I predict the code won't work because there's a ";" after return. -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 sum is undefined because the semicolon after return ends it too early, +the function returns before adding a and b.*/ // 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 12f14c153a3ca83e7c59c910444f3bc824902763 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 20:15:13 +0100 Subject: [PATCH 07/19] complete ex 2.js --- Sprint-3/2-mandatory-debug/2.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..5f4ce680b 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,9 +1,9 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> I predict the result will be wrong because the num is set set on 103. -const num = 103; +/*const num = 103; function getLastDigit() { return num.toString().slice(-1); @@ -11,14 +11,33 @@ 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 output: +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 problem is that the function ignores the numbers passed to it, + it always uses num, which is 103, so it returns 3 every time.*/ // Finally, correct the code to fix the problem // =============> write your new code here +/*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)}`);*/ // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem +// In this case getLastDigit is not working because it's parameter is empty and not declared. +// Here's the right code: +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)}`); From cdac639ba6525931702c2bf67a0165c3eb2d0ae1 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 21:57:41 +0100 Subject: [PATCH 08/19] complete ex 1-bmi.js --- Sprint-3/3-mandatory-implement/1-bmi.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..ba8f010d1 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,5 +15,6 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height + return (weight / (height * height)).toFixed(1); } +console.log(calculateBMI(52, 1.63)); From 4089ba33ce277a30f6c7807eb93a841c18c562c9 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 22:03:42 +0100 Subject: [PATCH 09/19] complete ex. 2-cases.js --- Sprint-3/3-mandatory-implement/2-cases.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..ae253e574 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/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 toUpperSnakeCase(words) { + return words.toUpperCase().replaceAll(" ", "_"); +} + +console.log(toUpperSnakeCase("hello there")); From acc0e01af425622fb63ce2139338dd9381ae8afe Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 22:14:58 +0100 Subject: [PATCH 10/19] complete ex 3-to-pounds.js --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 20 +++++++++++++++++++ 1 file changed, 20 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..9fe758f93 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,23 @@ // 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("599p")); +console.log(toPounds("6p")); +console.log(toPounds("2568p")); From f80713cb8a451a70373bbb3e8834c23e482cc254 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 22:55:44 +0100 Subject: [PATCH 11/19] complete ex time-format.js --- 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 c0dd9c9a5..be7bd335e 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -14,6 +14,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } +console.log(formatTimeDisplay(61)); // 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 @@ -21,18 +22,17 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============>Pad will be called 3 times: once for hours, once for minutes, and once for 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 +// =============> the first time pad is called, num gets the value of totalHours, which is 0. // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here - +// =============> the first time pad is called, it returns 00 because num is 0 and pad adds a zero in front. // 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 time pad is called, num is 1 because there is 1 second left. // 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 last time pad is called, it returns 01 because num is 1 and pad adds a 0 in front. From 86827f4b468e06970e63f23ef64f8389da3f405c Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 23:43:42 +0100 Subject: [PATCH 12/19] complete ex format-time.js --- Sprint-3/5-stretch-extend/format-time.js | 35 ++++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..fec322d91 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -3,23 +3,46 @@ // 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) { - const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; + const [hoursString, minutesString = "00"] = time.split(":"); + const hours = Number(hoursString); + const minutes = minutesString; + + let suffix = "am"; + if (hours >= 12) { + suffix = "pm"; + } + let formattedHours = hours % 12; + + if (formattedHours === 0) { + formattedHours = 12; } - return `${time} am`; + return `${formattedHours}:${minutes} ${suffix}`; } const currentOutput = formatAs12HourClock("08:00"); const targetOutput = "08:00 am"; console.assert( currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` + `current output: ${currentOutput}, target output: ${targetOutput}`, ); const currentOutput2 = formatAs12HourClock("23:00"); const targetOutput2 = "11:00 pm"; console.assert( currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` + `current output: ${currentOutput2}, target output: ${targetOutput2}`, +); +const noonOutput = formatAs12HourClock("12:00"); +const noonTarget = "12:00 pm"; +console.assert( + noonOutput === noonTarget, + `current output: ${noonOutput}, target output: ${noonTarget}`, +); + +const midnightOutput = formatAs12HourClock("00:00"); +const midnightTarget = "12:00 am"; +console.assert( + midnightOutput === midnightTarget, + `current output: ${midnightOutput}, target output: ${midnightTarget}`, ); +console.log("All tests passed"); From 9f55f62060c27c4982593d38b66e540b1db12a81 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Wed, 30 Sep 2026 23:53:09 +0100 Subject: [PATCH 13/19] Fix 12-hour clock conversion and add edge-case tests --- Sprint-3/5-stretch-extend/format-time.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index fec322d91..df1cba20f 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -11,11 +11,13 @@ function formatAs12HourClock(time) { if (hours >= 12) { suffix = "pm"; } + let formattedHours = hours % 12; if (formattedHours === 0) { formattedHours = 12; } + return `${formattedHours}:${minutes} ${suffix}`; } @@ -32,6 +34,7 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}`, ); + const noonOutput = formatAs12HourClock("12:00"); const noonTarget = "12:00 pm"; console.assert( @@ -45,4 +48,11 @@ console.assert( midnightOutput === midnightTarget, `current output: ${midnightOutput}, target output: ${midnightTarget}`, ); -console.log("All tests passed"); + +const minuteOutput = formatAs12HourClock("13:05"); +const minuteTarget = "01:05 pm"; +console.assert( + minuteOutput === minuteTarget, + `current output: ${minuteOutput}, target output: ${minuteTarget}`, +); +console.log("all tests passed"); From c566c35a07f4f025721e0f2737fd9318805dce39 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Thu, 1 Oct 2026 00:05:20 +0100 Subject: [PATCH 14/19] Fix time conversion --- Sprint-3/5-stretch-extend/format-time.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index df1cba20f..2038257e3 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -13,7 +13,6 @@ function formatAs12HourClock(time) { } let formattedHours = hours % 12; - if (formattedHours === 0) { formattedHours = 12; } @@ -21,13 +20,6 @@ function formatAs12HourClock(time) { return `${formattedHours}:${minutes} ${suffix}`; } -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}`, -); - const currentOutput2 = formatAs12HourClock("23:00"); const targetOutput2 = "11:00 pm"; console.assert( @@ -49,10 +41,4 @@ console.assert( `current output: ${midnightOutput}, target output: ${midnightTarget}`, ); -const minuteOutput = formatAs12HourClock("13:05"); -const minuteTarget = "01:05 pm"; -console.assert( - minuteOutput === minuteTarget, - `current output: ${minuteOutput}, target output: ${minuteTarget}`, -); -console.log("all tests passed"); +console.log("All formatAs12HourClock tests passed."); From ebea77662a65a045c2d7ea716b3bd241327e07ed Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Fri, 2 Oct 2026 10:57:52 +0100 Subject: [PATCH 15/19] Pad single-digit minutes in time formatter --- Sprint-3/5-stretch-extend/format-time.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 2038257e3..b6914afaf 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -5,7 +5,7 @@ function formatAs12HourClock(time) { const [hoursString, minutesString = "00"] = time.split(":"); const hours = Number(hoursString); - const minutes = minutesString; + const minutes = minutesString.padStart(2, "0"); let suffix = "am"; if (hours >= 12) { @@ -41,4 +41,11 @@ console.assert( `current output: ${midnightOutput}, target output: ${midnightTarget}`, ); +const singleDigitMinuteOutput = formatAs12HourClock("9:5"); +const singleDigitMinuteTarget = "9:05 am"; +console.assert( + singleDigitMinuteOutput === singleDigitMinuteTarget, + `current output: ${singleDigitMinuteOutput}, target output: ${singleDigitMinuteTarget}`, +); + console.log("All formatAs12HourClock tests passed."); From d6fd51e93362fd46d7211e773e54bf779e13d209 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Fri, 2 Oct 2026 11:06:07 +0100 Subject: [PATCH 16/19] Handle empty strings in capitalise function --- Sprint-3/1-key-errors/0.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 68feb4e3a..e11446e2e 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -14,8 +14,12 @@ capitalise("hello");*/ The function stops before it can run. */ // =============> write your new code here function capitalise(str) { + if (str === "") { + return ""; + } + const result = `${str[0].toUpperCase()}${str.slice(1)}`; return result; } -capitalise("hello"); -console.log(capitalise("hello")); + +console.log(`Result: "${capitalise("")}"`); From dc6b184e22e498ef5e39f23161cb3cf486a086da Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Fri, 2 Oct 2026 11:12:36 +0100 Subject: [PATCH 17/19] Format percentage output to one decimal place --- 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 3583921d0..9fb514925 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -21,7 +21,7 @@ console.log(decimalNumber);*/ // Finally, correct the code to fix the problem // =============> write your new code here function convertToPercentage(decimalNumber) { - const percentage = `${decimalNumber * 100}%`; + const percentage = `${(decimalNumber * 100).toFixed(1)}%`; return percentage; } From 60c151827b577a7083a54696f5d584ba0d31d33e Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Fri, 2 Oct 2026 11:29:15 +0100 Subject: [PATCH 18/19] Handle multiple spaces in case conversion --- 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 ae253e574..574482364 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -15,7 +15,7 @@ // 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(words) { - return words.toUpperCase().replaceAll(" ", "_"); + return words.toUpperCase().trim().split(/\s+/).join("_"); } console.log(toUpperSnakeCase("hello there")); From 8ee83a9e4f448381303a3b848658f95908f09296 Mon Sep 17 00:00:00 2001 From: Fatima Rouchi Date: Fri, 2 Oct 2026 11:36:01 +0100 Subject: [PATCH 19/19] Support pence values with or without the p suffix --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 9fe758f93..8562c5843 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -5,12 +5,9 @@ // 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 penceNumberString = String(penceString).replace(/p$/i, ""); + const paddedPenceNumberString = penceNumberString.padStart(3, "0"); - const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2,