From 576dc5a3fde6d5e62df1971510fb7c7a1e705e78 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Thu, 24 Sep 2026 21:56:04 +0100 Subject: [PATCH 01/26] Predicted what I expect, explained Syntax Error, added the new code --- Sprint-3/1-key-errors/0.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..053378f5e 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> I expect the function capitalise will turn first letter of string given by user into capital letter. // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -9,5 +9,9 @@ function capitalise(str) { return str; } -// =============> write your explanation here -// =============> write your new code here +// =============> The result was a Syntax error because str has been declared as parameter of function captialise before let reassign str. +// =============> +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} From 342efc6b88a1cd175eaef4fbc1b3ebe4ab36f9d2 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Thu, 24 Sep 2026 21:58:09 +0100 Subject: [PATCH 02/26] deleted old code in 0.js --- Sprint-3/1-key-errors/0.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 053378f5e..552605d40 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -4,11 +4,6 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} - // =============> The result was a Syntax error because str has been declared as parameter of function captialise before let reassign str. // =============> function capitalise(str) { From f47f36bfcd21c008f88477e1852948c596987521 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Thu, 24 Sep 2026 22:15:41 +0100 Subject: [PATCH 03/26] 1.js result predicted, explained the errors, and wrote new code --- Sprint-3/1-key-errors/1.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..82e7bf009 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,20 +1,26 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> SyntaxError will occurs // 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; -} +//function convertToPercentage(decimalNumber) { +//const decimalNumber = 0.5; +//const percentage = `${decimalNumber * 100}%`; -console.log(decimalNumber); +//return percentage; +//} -// =============> write your explanation here +//console.log(decimalNumber); +// =============> decimalNumber first declared as parameter, it cannot be reassigned as const. +// Also, console.log try to run decimalNumber as a variable while decimalNumber be assigned as a parameter. // 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 41e9a7adf083da4fe1cc56ca23b4c2d8a251607d Mon Sep 17 00:00:00 2001 From: debug2604 Date: Thu, 24 Sep 2026 22:16:35 +0100 Subject: [PATCH 04/26] 1.js old code deleted --- Sprint-3/1-key-errors/1.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 82e7bf009..102d2bae9 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -5,15 +5,6 @@ // 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); - // =============> decimalNumber first declared as parameter, it cannot be reassigned as const. // Also, console.log try to run decimalNumber as a variable while decimalNumber be assigned as a parameter. // Finally, correct the code to fix the problem From 9c61083bc30f515ea6ba9332672169d3d1cfa1a3 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Thu, 24 Sep 2026 22:25:05 +0100 Subject: [PATCH 05/26] 2.js SyntaxError expected, explained the error, wrote new code, deleted old code --- Sprint-3/1-key-errors/2.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..9b96755f0 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,17 @@ - // Predict and explain first BEFORE you run any code... // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here - -function square(3) { - return num * num; -} +// =============> I expect SyntaxError will result -// =============> write the error message here +// =============> SyntaxError: Unexpected number -// =============> explain this error message here +// =============> Numerical character "3" cannot be named as parameter of a function. // Finally, correct the code to fix the problem // =============> write your new code here - - +function square(num) { + return num * num; +} +console.log(square(3)); From 3ecd29631fa115c16b476b665697411d8e841650 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Fri, 25 Sep 2026 21:52:52 +0100 Subject: [PATCH 06/26] grammar correction --- Sprint-3/1-key-errors/1.js | 2 +- Sprint-3/Prep/demoTrackfile.txt | 0 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 Sprint-3/Prep/demoTrackfile.txt diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 102d2bae9..6a42a9427 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -6,7 +6,7 @@ // Try playing computer with the example to work out what is going on // =============> decimalNumber first declared as parameter, it cannot be reassigned as const. -// Also, console.log try to run decimalNumber as a variable while decimalNumber be assigned as a parameter. +// Also, console.log try to run decimalNumber as a variable while decimalNumber was assigned as a parameter. // Finally, correct the code to fix the problem // =============> write your new code here function convertToPercentage(decimalNumber) { diff --git a/Sprint-3/Prep/demoTrackfile.txt b/Sprint-3/Prep/demoTrackfile.txt new file mode 100644 index 000000000..e69de29bb From 55f005df6cf36dcd43654e2926654efb50806a71 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 26 Sep 2026 17:04:04 +0100 Subject: [PATCH 07/26] 2-mandatory-debug 0.jsedited, expectation stated, code fixed --- Sprint-3/2-mandatory-debug/0.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..345d437c6 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,20 @@ // Predict and explain first... -// =============> write your prediction here +// =============> console.log in local function will result the product. But console.log in global scope will not call function multiply. +//function multiply(a, b) { +// console.log(a * b); +//} + +//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); + +// =============> The function multiply does not really carry out the multiplication. It only logs the result of a*b. That's why calling multiply become undefined. +// Finally, correct the code to fix the problem +// =============> write your new code here function multiply(a, b) { - console.log(a * b); + return a * b; } console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here - -// Finally, correct the code to fix the problem -// =============> write your new code here + From bc686426001a74097820cbef354d751dcf5e7103 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 26 Sep 2026 17:06:32 +0100 Subject: [PATCH 08/26] 2-manadatory-debug 0.js edited, expectation stated --- Sprint-3/Prep/sixToast | 48 +++++++++++++++++++++++++++++++++++++++ Sprint-3/Prep/sixToast.js | 39 +++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Sprint-3/Prep/sixToast create mode 100644 Sprint-3/Prep/sixToast.js diff --git a/Sprint-3/Prep/sixToast b/Sprint-3/Prep/sixToast new file mode 100644 index 000000000..4dbb907ef --- /dev/null +++ b/Sprint-3/Prep/sixToast @@ -0,0 +1,48 @@ +const Capacity = 6 + +function sixToast(num) { + + let response; + let Capacity - sixToast = howmanymoreorless; + + if (howmanymoreorless> 0) { + + response = "put `howmanymoreorless` toast"; + + } + + else if (howmanymoreorless = 0){ + + response = "toast count just right"; + } + + else (howmanymoreorless < 0) { + response = "toast overflow take 'howmanymoreorless' away" + } + +} + + console.log(response) + + + + +//initial thoughts +//set sixToast = 6 turn into set capacity = 6 +//input sixTost =(user input) is parameter , and arguments +//6 - num (argument) = howmanymoreorless +//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" +//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" + +//keys: +// capacity: number of toast process each time +//sixToast: count of toast put into +//howManymoreorless : the number need more or less + +//arithmetics: + + // howManymoreorless = sixToast -toastPutinto + // howManymoreorless = sixToast - num + // howManymoreorless = 6 - num + +//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file diff --git a/Sprint-3/Prep/sixToast.js b/Sprint-3/Prep/sixToast.js new file mode 100644 index 000000000..77490301e --- /dev/null +++ b/Sprint-3/Prep/sixToast.js @@ -0,0 +1,39 @@ +const Capacity = 6 + +function sixToast(num) { + const howmanymoreorless = Capacity - num; + + if (howmanymoreorless > 0) { + return `Put ${howmanymoreorless} more toast${howmanymoreorless === 1 ? "" : "s"}.`; + } + + if (howmanymoreorless === 0) { + return "Toast count is just right."; + } + + return `Toast overflow: take ${Math.abs(howmanymoreorless)} toast${Math.abs(howmanymoreorless) === 1 ? "" : "s"} away.`; +} + +console.log(sixToast(2)); +console.log(sixToast(6)); +console.log(sixToast(7)); + +//initial thoughts +//set sixToast = 6 turn into set capacity = 6 +//input sixTost =(user input) is parameter , and arguments +//6 - num (argument) = howmanymoreorless +//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" +//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" + +//keys: +// capacity: number of toast process each time +//sixToast: count of toast put into +//howManymoreorless : the number need more or less + +//arithmetics: + + // howManymoreorless = sixToast -toastPutinto + // howManymoreorless = sixToast - num + // howManymoreorless = 6 - num + +//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file From a243d6d24d94722a0211b096adae7b5ec5906aec Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 26 Sep 2026 17:22:33 +0100 Subject: [PATCH 09/26] 2-mandatory-debug 1.jsedited, expectation stated, code fixed --- Sprint-3/2-mandatory-debug/1.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..978eb0ef4 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,18 @@ // Predict and explain first... -// =============> write your prediction here +// =============> I predict a SyntaxError in original code -function sum(a, b) { - return; - a + b; -} +//function sum(a, b) { +// return; +// a + b; +//} -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); +//console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> Expression a + b is not assigned to return. // 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)}`); \ No newline at end of file From 1b096215b830aef6381aa3c642c1ccca4ffd6621 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Sun, 27 Sep 2026 17:48:45 +0100 Subject: [PATCH 10/26] 2-mandatory-debug 0.js added Undefined in expectation. --- Sprint-3/2-mandatory-debug/0.js | 6 ++---- Sprint-3/I | 0 Sprint-3/Prep/.gitattributes | 0 Sprint-3/Prep/Math-round | 5 +++++ Sprint-3/Prep/demoTrackfile.txt | 1 + Sprint-3/Prep/demoUNtrackedfile.txt | 1 + Sprint-3/Prep/passwordCheckerFunction.js | 16 ++++++++++++++++ Sprint-3/The | 0 8 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 Sprint-3/I create mode 100644 Sprint-3/Prep/.gitattributes create mode 100644 Sprint-3/Prep/Math-round create mode 100644 Sprint-3/Prep/demoUNtrackedfile.txt create mode 100644 Sprint-3/Prep/passwordCheckerFunction.js create mode 100644 Sprint-3/The diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 345d437c6..25da8e34c 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,6 +1,6 @@ // Predict and explain first... -// =============> console.log in local function will result the product. But console.log in global scope will not call function multiply. +// =============> Undefined. console.log in local function will result the product. But console.log in global scope will not call function multiply. //function multiply(a, b) { // console.log(a * b); @@ -8,7 +8,7 @@ //console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> The function multiply does not really carry out the multiplication. It only logs the result of a*b. That's why calling multiply become undefined. +// =============> The function multiply does not really carry out the multiplication. It only logs the result of a*b. That's why calling multiply become undefined. // Finally, correct the code to fix the problem // =============> write your new code here function multiply(a, b) { @@ -16,5 +16,3 @@ function multiply(a, b) { } console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); - - diff --git a/Sprint-3/I b/Sprint-3/I new file mode 100644 index 000000000..e69de29bb diff --git a/Sprint-3/Prep/.gitattributes b/Sprint-3/Prep/.gitattributes new file mode 100644 index 000000000..e69de29bb diff --git a/Sprint-3/Prep/Math-round b/Sprint-3/Prep/Math-round new file mode 100644 index 000000000..037291c33 --- /dev/null +++ b/Sprint-3/Prep/Math-round @@ -0,0 +1,5 @@ +Math.round(0.00005); +let round = Math.round(0.00004); + +round = round + 10; +console.log(round); diff --git a/Sprint-3/Prep/demoTrackfile.txt b/Sprint-3/Prep/demoTrackfile.txt index e69de29bb..2e5c0b104 100644 --- a/Sprint-3/Prep/demoTrackfile.txt +++ b/Sprint-3/Prep/demoTrackfile.txt @@ -0,0 +1 @@ +this is a file to demo tracking file \ No newline at end of file diff --git a/Sprint-3/Prep/demoUNtrackedfile.txt b/Sprint-3/Prep/demoUNtrackedfile.txt new file mode 100644 index 000000000..4c67e252b --- /dev/null +++ b/Sprint-3/Prep/demoUNtrackedfile.txt @@ -0,0 +1 @@ +This is untracked file demo \ No newline at end of file diff --git a/Sprint-3/Prep/passwordCheckerFunction.js b/Sprint-3/Prep/passwordCheckerFunction.js new file mode 100644 index 000000000..5724bef8f --- /dev/null +++ b/Sprint-3/Prep/passwordCheckerFunction.js @@ -0,0 +1,16 @@ +//passwordCheckerFunction + +const password = "secretworld123"; //A password value stored + +function passwordChecker(userInput) { + //Compare user input with password stored + if (userInput === password) { + //then response if password is correct + console.log("password is correct"); + } else { + //else response if password is incorrect + console.log("password is not correct, please try again"); + } +} + +passwordChecker("Helloworld125"); diff --git a/Sprint-3/The b/Sprint-3/The new file mode 100644 index 000000000..e69de29bb From 742ac3f95d8a6c371555208d90073fc97fabd048 Mon Sep 17 00:00:00 2001 From: debug2604 Date: Sun, 27 Sep 2026 18:18:11 +0100 Subject: [PATCH 11/26] 2-mandatory-debug 2.js edited, result predicted, prediction compared, explained, and code corrected. --- Sprint-3/2-mandatory-debug/2.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..705cd3563 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,11 +1,30 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> Code returns last digit of 103 which is the value of num assigned in global scope. +//const num = 103; + +//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)}`); + +// Now run the code and compare the output to your prediction +// =============> +// 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 +// =============> The function refers to the value of `num` assigned in global scope rather than getLastDigit, because 'num' was not a parameter in function name. +// Finally, correct the code to fix the problem +// =============> const num = 103; -function getLastDigit() { +function getLastDigit(num) { return num.toString().slice(-1); } @@ -13,12 +32,5 @@ console.log(`The last digit of 42 is ${getLastDigit(42)}`); console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); -// Now run the code and compare the output to your prediction -// =============> write the output here -// Explain why the output is the way it is -// =============> write your explanation here -// Finally, correct the code to fix the problem -// =============> write your new code here - // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 9ba67d2025bbf2214cd2481fcc8435f2e0cea299 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 27 Sep 2026 20:53:07 +0100 Subject: [PATCH 12/26] 3-mandatory-implement 1-bmi.js Implemented BMI calculation function and log result to one decimal place --- Sprint-3/3-mandatory-implement/1-bmi.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..ff155e09b 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -16,4 +16,17 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height + return weight / Math.pow(height, 2); } + +console.log( + `BMI base off weight in kg and height in metres is ${calculateBMI(70, 1.73).toFixed(1)}`, +); + +//draft pseudocode below +//name of function calculateBMI +//key word return +//parameters : weight, height +//formula weight / height x height +//or weight / sqr height (by Method: Math.pow(parameter,power)) +//display BMI in one decimal place From 6be655b37c05c54d90d28788b53010305b02fe1c Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 27 Sep 2026 20:56:33 +0100 Subject: [PATCH 13/26] Fix typo in comment explaining undefined behavior in multiply function --- Sprint-3/2-mandatory-debug/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 25da8e34c..2a0737b02 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,6 +1,6 @@ // Predict and explain first... -// =============> Undefined. console.log in local function will result the product. But console.log in global scope will not call function multiply. +// =============> Undefined at the end of sentence. console.log in local function will result the product. But console.log in global scope will not call function multiply. //function multiply(a, b) { // console.log(a * b); From cf2bf33448f4707687b2c522176350c658bf5dac Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 27 Sep 2026 21:25:35 +0100 Subject: [PATCH 14/26] 3-mandatory-implement 2-cases.js Implemented upperSnakeCase function to convert strings to UPPER_SNAKE_CASE format --- Sprint-3/3-mandatory-implement/2-cases.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..bb1ada7b4 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,14 @@ // 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 + +//pseudocode draft below +//Name of function upperSnakeCase +//Parameter (userInputString) type: String +//Method .toUpperCase() .replaceAll("","_") +//print by console.log (`${userInputString()`}) + +function upperSnakeCase(userInputString) { + return userInputString.toUpperCase().replaceAll(" ", "_"); +} +console.log(upperSnakeCase("hello world")); From 9a86ff0e9d67488a5974b1c9bcf7c7402e45c898 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 11:02:14 +0100 Subject: [PATCH 15/26] 3-mandatory-implement 3-to-pounds.js Implement toPound function to convert whole pence string to formatted pounds --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 29 +++++++++++++++++++ 1 file changed, 29 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..aca706c4f 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/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 name toPound +//identifier of prev code : +// 1 penceString - user input ; Type: String, count length by .length +// 2 penceStringWithoutTrailingP ; cut the tail p by .substring () +// 3 paddedPenceNumberString ; assign and prescribe target length of pence in three characters length by .padStart() +// 4 pounds ; assign pounds from first character of paddedPenceNumberString, cut the last two character by .substring +// 5 pence ; assign pence starting from last two character of paddedPenceNumberString +// Parameter to name penceStringWithP + +function toPound(wholePenceStringWithP) { + const penceStringWithoutTrailingP = wholePenceStringWithP.substring( + 0, + wholePenceStringWithP.length - 1, + ); + + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2, + ); + + const pence = paddedPenceNumberString.substring( + paddedPenceNumberString.length - 2, + ); + + return `£${pounds}.${pence}`; +} +console.log(toPound("399p")); From 0142183cf3d283a35ab76ed34fde678b58aa7b7f Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 12:01:07 +0100 Subject: [PATCH 16/26] 3-to-pound.js : Refactor parameter name (wholePenceStringWithP) in toPound function for clarity; time-format.js updated comments with answers to questions --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 2 +- Sprint-3/4-mandatory-interpret/time-format.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index aca706c4f..49d2ee05c 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -12,7 +12,7 @@ // 3 paddedPenceNumberString ; assign and prescribe target length of pence in three characters length by .padStart() // 4 pounds ; assign pounds from first character of paddedPenceNumberString, cut the last two character by .substring // 5 pence ; assign pence starting from last two character of paddedPenceNumberString -// Parameter to name penceStringWithP +// Parameter to name wholePenceStringWithP function toPound(wholePenceStringWithP) { const penceStringWithoutTrailingP = wholePenceStringWithP.substring( diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..da5cf085c 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -15,24 +15,25 @@ 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 // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> Three 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 when it 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. The last pad call takes `remainingSeconds` as its argument, and 61 % 60 =1 , so num is 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 +// =============> 01. `numString` starts as "1", which has one character length. Since 1 < 1, the while lines run and pad "0", giving "01". Now this new `numString` has two characters length, so the while loop stops and returns "01". From c4affdd6c048fb6ba08f30d616f6cda939c5b249 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 14:56:59 +0100 Subject: [PATCH 17/26] formatTime.js formatAs12HourClock function to correctly handle hour inputs over 24 and update test cases for clarity, also handle minutes input other than :00 --- Sprint-3/5-stretch-extend/format-time.js | 34 +++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..13669f81b 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -4,22 +4,42 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; + const minutes = time.slice(3); + if (hours > 24) { + return `${hours - 24}:${minutes} am +1`; + } else if (hours > 12) { + return `${hours - 12}:${minutes} pm`; } - return `${time} am`; + return `${hours}:${minutes} am`; } -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; +const currentOutput = formatAs12HourClock("08:01"); +const targetOutput = "8:01 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 currentOutput3 = formatAs12HourClock("25:00"); +const targetOutput3 = "1:00 am +1"; +console.assert( + currentOutput3 === targetOutput3, + `current output: ${currentOutput3}, target output: ${targetOutput3}`, +); + +console.log(formatAs12HourClock("08:01")); +console.log(formatAs12HourClock("23:55")); +console.log(formatAs12HourClock("25:01")); + +//Two patches +//First hour input > 24, current algo is hours - 12 , e.g. 25-12 and print 13:00pm , rather than 1:00am (+1) +//to Define `hoursOfOneDay` = 24 +//2 min input +//to Define From d35a84695f740211a414b57f6e0bac4802b8d1e3 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 18:06:51 +0100 Subject: [PATCH 18/26] Remove Prep folder files from PR --- Sprint-3/Prep/.gitattributes | 0 Sprint-3/Prep/Math-round | 5 --- Sprint-3/Prep/demoTrackfile.txt | 1 - Sprint-3/Prep/demoUNtrackedfile.txt | 1 - Sprint-3/Prep/passwordCheckerFunction.js | 16 -------- Sprint-3/Prep/sixToast | 48 ------------------------ Sprint-3/Prep/sixToast.js | 39 ------------------- 7 files changed, 110 deletions(-) delete mode 100644 Sprint-3/Prep/.gitattributes delete mode 100644 Sprint-3/Prep/Math-round delete mode 100644 Sprint-3/Prep/demoTrackfile.txt delete mode 100644 Sprint-3/Prep/demoUNtrackedfile.txt delete mode 100644 Sprint-3/Prep/passwordCheckerFunction.js delete mode 100644 Sprint-3/Prep/sixToast delete mode 100644 Sprint-3/Prep/sixToast.js diff --git a/Sprint-3/Prep/.gitattributes b/Sprint-3/Prep/.gitattributes deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint-3/Prep/Math-round b/Sprint-3/Prep/Math-round deleted file mode 100644 index 037291c33..000000000 --- a/Sprint-3/Prep/Math-round +++ /dev/null @@ -1,5 +0,0 @@ -Math.round(0.00005); -let round = Math.round(0.00004); - -round = round + 10; -console.log(round); diff --git a/Sprint-3/Prep/demoTrackfile.txt b/Sprint-3/Prep/demoTrackfile.txt deleted file mode 100644 index 2e5c0b104..000000000 --- a/Sprint-3/Prep/demoTrackfile.txt +++ /dev/null @@ -1 +0,0 @@ -this is a file to demo tracking file \ No newline at end of file diff --git a/Sprint-3/Prep/demoUNtrackedfile.txt b/Sprint-3/Prep/demoUNtrackedfile.txt deleted file mode 100644 index 4c67e252b..000000000 --- a/Sprint-3/Prep/demoUNtrackedfile.txt +++ /dev/null @@ -1 +0,0 @@ -This is untracked file demo \ No newline at end of file diff --git a/Sprint-3/Prep/passwordCheckerFunction.js b/Sprint-3/Prep/passwordCheckerFunction.js deleted file mode 100644 index 5724bef8f..000000000 --- a/Sprint-3/Prep/passwordCheckerFunction.js +++ /dev/null @@ -1,16 +0,0 @@ -//passwordCheckerFunction - -const password = "secretworld123"; //A password value stored - -function passwordChecker(userInput) { - //Compare user input with password stored - if (userInput === password) { - //then response if password is correct - console.log("password is correct"); - } else { - //else response if password is incorrect - console.log("password is not correct, please try again"); - } -} - -passwordChecker("Helloworld125"); diff --git a/Sprint-3/Prep/sixToast b/Sprint-3/Prep/sixToast deleted file mode 100644 index 4dbb907ef..000000000 --- a/Sprint-3/Prep/sixToast +++ /dev/null @@ -1,48 +0,0 @@ -const Capacity = 6 - -function sixToast(num) { - - let response; - let Capacity - sixToast = howmanymoreorless; - - if (howmanymoreorless> 0) { - - response = "put `howmanymoreorless` toast"; - - } - - else if (howmanymoreorless = 0){ - - response = "toast count just right"; - } - - else (howmanymoreorless < 0) { - response = "toast overflow take 'howmanymoreorless' away" - } - -} - - console.log(response) - - - - -//initial thoughts -//set sixToast = 6 turn into set capacity = 6 -//input sixTost =(user input) is parameter , and arguments -//6 - num (argument) = howmanymoreorless -//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" -//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" - -//keys: -// capacity: number of toast process each time -//sixToast: count of toast put into -//howManymoreorless : the number need more or less - -//arithmetics: - - // howManymoreorless = sixToast -toastPutinto - // howManymoreorless = sixToast - num - // howManymoreorless = 6 - num - -//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file diff --git a/Sprint-3/Prep/sixToast.js b/Sprint-3/Prep/sixToast.js deleted file mode 100644 index 77490301e..000000000 --- a/Sprint-3/Prep/sixToast.js +++ /dev/null @@ -1,39 +0,0 @@ -const Capacity = 6 - -function sixToast(num) { - const howmanymoreorless = Capacity - num; - - if (howmanymoreorless > 0) { - return `Put ${howmanymoreorless} more toast${howmanymoreorless === 1 ? "" : "s"}.`; - } - - if (howmanymoreorless === 0) { - return "Toast count is just right."; - } - - return `Toast overflow: take ${Math.abs(howmanymoreorless)} toast${Math.abs(howmanymoreorless) === 1 ? "" : "s"} away.`; -} - -console.log(sixToast(2)); -console.log(sixToast(6)); -console.log(sixToast(7)); - -//initial thoughts -//set sixToast = 6 turn into set capacity = 6 -//input sixTost =(user input) is parameter , and arguments -//6 - num (argument) = howmanymoreorless -//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" -//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" - -//keys: -// capacity: number of toast process each time -//sixToast: count of toast put into -//howManymoreorless : the number need more or less - -//arithmetics: - - // howManymoreorless = sixToast -toastPutinto - // howManymoreorless = sixToast - num - // howManymoreorless = 6 - num - -//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file From 214b717b5658ca727a1c26a6d6db3e84dcac288f Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 18:13:46 +0100 Subject: [PATCH 19/26] Removed empty files --- Sprint-3/{I => Prep/.gitattributes} | 0 Sprint-3/{The => Prep/.gitignore} | 0 Sprint-3/Prep/I | 0 Sprint-3/Prep/Math-round | 5 +++ Sprint-3/Prep/The | 0 Sprint-3/Prep/demoTrackfile.txt | 1 + Sprint-3/Prep/demoUNtrackedfile.txt | 1 + Sprint-3/Prep/passwordCheckerFunction.js | 16 ++++++++ Sprint-3/Prep/sixToast | 48 ++++++++++++++++++++++++ Sprint-3/Prep/sixToast.js | 39 +++++++++++++++++++ 10 files changed, 110 insertions(+) rename Sprint-3/{I => Prep/.gitattributes} (100%) rename Sprint-3/{The => Prep/.gitignore} (100%) create mode 100644 Sprint-3/Prep/I create mode 100644 Sprint-3/Prep/Math-round create mode 100644 Sprint-3/Prep/The create mode 100644 Sprint-3/Prep/demoTrackfile.txt create mode 100644 Sprint-3/Prep/demoUNtrackedfile.txt create mode 100644 Sprint-3/Prep/passwordCheckerFunction.js create mode 100644 Sprint-3/Prep/sixToast create mode 100644 Sprint-3/Prep/sixToast.js diff --git a/Sprint-3/I b/Sprint-3/Prep/.gitattributes similarity index 100% rename from Sprint-3/I rename to Sprint-3/Prep/.gitattributes diff --git a/Sprint-3/The b/Sprint-3/Prep/.gitignore similarity index 100% rename from Sprint-3/The rename to Sprint-3/Prep/.gitignore diff --git a/Sprint-3/Prep/I b/Sprint-3/Prep/I new file mode 100644 index 000000000..e69de29bb diff --git a/Sprint-3/Prep/Math-round b/Sprint-3/Prep/Math-round new file mode 100644 index 000000000..037291c33 --- /dev/null +++ b/Sprint-3/Prep/Math-round @@ -0,0 +1,5 @@ +Math.round(0.00005); +let round = Math.round(0.00004); + +round = round + 10; +console.log(round); diff --git a/Sprint-3/Prep/The b/Sprint-3/Prep/The new file mode 100644 index 000000000..e69de29bb diff --git a/Sprint-3/Prep/demoTrackfile.txt b/Sprint-3/Prep/demoTrackfile.txt new file mode 100644 index 000000000..2e5c0b104 --- /dev/null +++ b/Sprint-3/Prep/demoTrackfile.txt @@ -0,0 +1 @@ +this is a file to demo tracking file \ No newline at end of file diff --git a/Sprint-3/Prep/demoUNtrackedfile.txt b/Sprint-3/Prep/demoUNtrackedfile.txt new file mode 100644 index 000000000..4c67e252b --- /dev/null +++ b/Sprint-3/Prep/demoUNtrackedfile.txt @@ -0,0 +1 @@ +This is untracked file demo \ No newline at end of file diff --git a/Sprint-3/Prep/passwordCheckerFunction.js b/Sprint-3/Prep/passwordCheckerFunction.js new file mode 100644 index 000000000..5724bef8f --- /dev/null +++ b/Sprint-3/Prep/passwordCheckerFunction.js @@ -0,0 +1,16 @@ +//passwordCheckerFunction + +const password = "secretworld123"; //A password value stored + +function passwordChecker(userInput) { + //Compare user input with password stored + if (userInput === password) { + //then response if password is correct + console.log("password is correct"); + } else { + //else response if password is incorrect + console.log("password is not correct, please try again"); + } +} + +passwordChecker("Helloworld125"); diff --git a/Sprint-3/Prep/sixToast b/Sprint-3/Prep/sixToast new file mode 100644 index 000000000..4dbb907ef --- /dev/null +++ b/Sprint-3/Prep/sixToast @@ -0,0 +1,48 @@ +const Capacity = 6 + +function sixToast(num) { + + let response; + let Capacity - sixToast = howmanymoreorless; + + if (howmanymoreorless> 0) { + + response = "put `howmanymoreorless` toast"; + + } + + else if (howmanymoreorless = 0){ + + response = "toast count just right"; + } + + else (howmanymoreorless < 0) { + response = "toast overflow take 'howmanymoreorless' away" + } + +} + + console.log(response) + + + + +//initial thoughts +//set sixToast = 6 turn into set capacity = 6 +//input sixTost =(user input) is parameter , and arguments +//6 - num (argument) = howmanymoreorless +//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" +//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" + +//keys: +// capacity: number of toast process each time +//sixToast: count of toast put into +//howManymoreorless : the number need more or less + +//arithmetics: + + // howManymoreorless = sixToast -toastPutinto + // howManymoreorless = sixToast - num + // howManymoreorless = 6 - num + +//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file diff --git a/Sprint-3/Prep/sixToast.js b/Sprint-3/Prep/sixToast.js new file mode 100644 index 000000000..77490301e --- /dev/null +++ b/Sprint-3/Prep/sixToast.js @@ -0,0 +1,39 @@ +const Capacity = 6 + +function sixToast(num) { + const howmanymoreorless = Capacity - num; + + if (howmanymoreorless > 0) { + return `Put ${howmanymoreorless} more toast${howmanymoreorless === 1 ? "" : "s"}.`; + } + + if (howmanymoreorless === 0) { + return "Toast count is just right."; + } + + return `Toast overflow: take ${Math.abs(howmanymoreorless)} toast${Math.abs(howmanymoreorless) === 1 ? "" : "s"} away.`; +} + +console.log(sixToast(2)); +console.log(sixToast(6)); +console.log(sixToast(7)); + +//initial thoughts +//set sixToast = 6 turn into set capacity = 6 +//input sixTost =(user input) is parameter , and arguments +//6 - num (argument) = howmanymoreorless +//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" +//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" + +//keys: +// capacity: number of toast process each time +//sixToast: count of toast put into +//howManymoreorless : the number need more or less + +//arithmetics: + + // howManymoreorless = sixToast -toastPutinto + // howManymoreorless = sixToast - num + // howManymoreorless = 6 - num + +//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file From 8e32548d7f2b96923898ce72e59ca2b56f3166a7 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 18:16:36 +0100 Subject: [PATCH 20/26] Remove Prep files from PR --- Sprint-3/Prep/.gitattributes | 0 Sprint-3/Prep/.gitignore | 0 Sprint-3/Prep/I | 0 Sprint-3/Prep/Math-round | 5 --- Sprint-3/Prep/The | 0 Sprint-3/Prep/demoTrackfile.txt | 1 - Sprint-3/Prep/demoUNtrackedfile.txt | 1 - Sprint-3/Prep/passwordCheckerFunction.js | 16 -------- Sprint-3/Prep/sixToast | 48 ------------------------ Sprint-3/Prep/sixToast.js | 39 ------------------- 10 files changed, 110 deletions(-) delete mode 100644 Sprint-3/Prep/.gitattributes delete mode 100644 Sprint-3/Prep/.gitignore delete mode 100644 Sprint-3/Prep/I delete mode 100644 Sprint-3/Prep/Math-round delete mode 100644 Sprint-3/Prep/The delete mode 100644 Sprint-3/Prep/demoTrackfile.txt delete mode 100644 Sprint-3/Prep/demoUNtrackedfile.txt delete mode 100644 Sprint-3/Prep/passwordCheckerFunction.js delete mode 100644 Sprint-3/Prep/sixToast delete mode 100644 Sprint-3/Prep/sixToast.js diff --git a/Sprint-3/Prep/.gitattributes b/Sprint-3/Prep/.gitattributes deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint-3/Prep/.gitignore b/Sprint-3/Prep/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint-3/Prep/I b/Sprint-3/Prep/I deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint-3/Prep/Math-round b/Sprint-3/Prep/Math-round deleted file mode 100644 index 037291c33..000000000 --- a/Sprint-3/Prep/Math-round +++ /dev/null @@ -1,5 +0,0 @@ -Math.round(0.00005); -let round = Math.round(0.00004); - -round = round + 10; -console.log(round); diff --git a/Sprint-3/Prep/The b/Sprint-3/Prep/The deleted file mode 100644 index e69de29bb..000000000 diff --git a/Sprint-3/Prep/demoTrackfile.txt b/Sprint-3/Prep/demoTrackfile.txt deleted file mode 100644 index 2e5c0b104..000000000 --- a/Sprint-3/Prep/demoTrackfile.txt +++ /dev/null @@ -1 +0,0 @@ -this is a file to demo tracking file \ No newline at end of file diff --git a/Sprint-3/Prep/demoUNtrackedfile.txt b/Sprint-3/Prep/demoUNtrackedfile.txt deleted file mode 100644 index 4c67e252b..000000000 --- a/Sprint-3/Prep/demoUNtrackedfile.txt +++ /dev/null @@ -1 +0,0 @@ -This is untracked file demo \ No newline at end of file diff --git a/Sprint-3/Prep/passwordCheckerFunction.js b/Sprint-3/Prep/passwordCheckerFunction.js deleted file mode 100644 index 5724bef8f..000000000 --- a/Sprint-3/Prep/passwordCheckerFunction.js +++ /dev/null @@ -1,16 +0,0 @@ -//passwordCheckerFunction - -const password = "secretworld123"; //A password value stored - -function passwordChecker(userInput) { - //Compare user input with password stored - if (userInput === password) { - //then response if password is correct - console.log("password is correct"); - } else { - //else response if password is incorrect - console.log("password is not correct, please try again"); - } -} - -passwordChecker("Helloworld125"); diff --git a/Sprint-3/Prep/sixToast b/Sprint-3/Prep/sixToast deleted file mode 100644 index 4dbb907ef..000000000 --- a/Sprint-3/Prep/sixToast +++ /dev/null @@ -1,48 +0,0 @@ -const Capacity = 6 - -function sixToast(num) { - - let response; - let Capacity - sixToast = howmanymoreorless; - - if (howmanymoreorless> 0) { - - response = "put `howmanymoreorless` toast"; - - } - - else if (howmanymoreorless = 0){ - - response = "toast count just right"; - } - - else (howmanymoreorless < 0) { - response = "toast overflow take 'howmanymoreorless' away" - } - -} - - console.log(response) - - - - -//initial thoughts -//set sixToast = 6 turn into set capacity = 6 -//input sixTost =(user input) is parameter , and arguments -//6 - num (argument) = howmanymoreorless -//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" -//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" - -//keys: -// capacity: number of toast process each time -//sixToast: count of toast put into -//howManymoreorless : the number need more or less - -//arithmetics: - - // howManymoreorless = sixToast -toastPutinto - // howManymoreorless = sixToast - num - // howManymoreorless = 6 - num - -//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file diff --git a/Sprint-3/Prep/sixToast.js b/Sprint-3/Prep/sixToast.js deleted file mode 100644 index 77490301e..000000000 --- a/Sprint-3/Prep/sixToast.js +++ /dev/null @@ -1,39 +0,0 @@ -const Capacity = 6 - -function sixToast(num) { - const howmanymoreorless = Capacity - num; - - if (howmanymoreorless > 0) { - return `Put ${howmanymoreorless} more toast${howmanymoreorless === 1 ? "" : "s"}.`; - } - - if (howmanymoreorless === 0) { - return "Toast count is just right."; - } - - return `Toast overflow: take ${Math.abs(howmanymoreorless)} toast${Math.abs(howmanymoreorless) === 1 ? "" : "s"} away.`; -} - -console.log(sixToast(2)); -console.log(sixToast(6)); -console.log(sixToast(7)); - -//initial thoughts -//set sixToast = 6 turn into set capacity = 6 -//input sixTost =(user input) is parameter , and arguments -//6 - num (argument) = howmanymoreorless -//if howmanymoreorless > 0 return "put `howmanymoreorless` toast" -//if howmanymoreorless < 0 retrurn "toaster is full, take away abs(howmanymoreorless)" - -//keys: -// capacity: number of toast process each time -//sixToast: count of toast put into -//howManymoreorless : the number need more or less - -//arithmetics: - - // howManymoreorless = sixToast -toastPutinto - // howManymoreorless = sixToast - num - // howManymoreorless = 6 - num - -//sixToast -toastPutinto = absolute count of howManymoreorless \ No newline at end of file From 1d3a340ddf9d30d1a5b988bd4d6f656891ce4dba Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 28 Sep 2026 20:29:58 +0100 Subject: [PATCH 21/26] 3-to-pound.js: added test cases --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 49d2ee05c..a049229fa 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -33,3 +33,6 @@ function toPound(wholePenceStringWithP) { return `£${pounds}.${pence}`; } console.log(toPound("399p")); +console.log(toPound("1399p")); +console.log(toPound("99p")); +console.log(toPound("9p")); \ No newline at end of file From b8dc4706e727be344cdd5cab01a4a415cfb3c1d2 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 29 Sep 2026 23:15:38 +0100 Subject: [PATCH 22/26] use by Method .toFixed(1) to return BMI in string in one decimal place --- Sprint-3/3-mandatory-implement/1-bmi.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index ff155e09b..e410c6f10 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -16,11 +16,11 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height - return weight / Math.pow(height, 2); + return (weight / Math.pow(height, 2)).toFixed(1); } console.log( - `BMI base off weight in kg and height in metres is ${calculateBMI(70, 1.73).toFixed(1)}`, + `BMI base off weight in kg and height in metres is ${calculateBMI(70, 1.73)}`, ); //draft pseudocode below @@ -29,4 +29,4 @@ console.log( //parameters : weight, height //formula weight / height x height //or weight / sqr height (by Method: Math.pow(parameter,power)) -//display BMI in one decimal place +//by Method .toFixed(1) to return BMI in string in one decimal place From 773c6bcb8f87050c16501054352f208e66254c0e Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 29 Sep 2026 23:29:30 +0100 Subject: [PATCH 23/26] format-time.js edited to run `const` minutes =time.slice(-2); and fixed if (hours >= 24) (previous >24) --- Sprint-3/5-stretch-extend/format-time.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 13669f81b..c1668476d 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -4,8 +4,8 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); - const minutes = time.slice(3); - if (hours > 24) { + const minutes = time.slice(-2); + if (hours >= 24) { return `${hours - 24}:${minutes} am +1`; } else if (hours > 12) { return `${hours - 12}:${minutes} pm`; From 01c7b46e7244f616d4f703081758efd731e76a81 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Tue, 29 Sep 2026 23:53:34 +0100 Subject: [PATCH 24/26] Fix time formatting for hours >= 24 and ensure leading zeros for single-digit hours --- Sprint-3/5-stretch-extend/format-time.js | 26 ++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index c1668476d..7d40247cd 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -6,15 +6,17 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); const minutes = time.slice(-2); if (hours >= 24) { - return `${hours - 24}:${minutes} am +1`; + return `0${hours - 24}:${minutes} am +1`; } else if (hours > 12) { return `${hours - 12}:${minutes} pm`; + } else if (hours > 9) { + return `${hours}:${minutes} am`; } - return `${hours}:${minutes} am`; + return `0${hours}:${minutes} am`; } const currentOutput = formatAs12HourClock("08:01"); -const targetOutput = "8:01 am"; +const targetOutput = "08:01 am"; console.assert( currentOutput === targetOutput, `current output: ${currentOutput}, target output: ${targetOutput}`, @@ -28,15 +30,31 @@ console.assert( ); const currentOutput3 = formatAs12HourClock("25:00"); -const targetOutput3 = "1:00 am +1"; +const targetOutput3 = "01:00 am +1"; console.assert( currentOutput3 === targetOutput3, `current output: ${currentOutput3}, target output: ${targetOutput3}`, ); +const currentOutput4 = formatAs12HourClock("00:01"); +const targetOutput4 = "00:01 am"; +console.assert( + currentOutput4 === targetOutput4, + `current output: ${currentOutput4}, target output: ${targetOutput4}`, +); + +const currentOutput5 = formatAs12HourClock("11:01"); +const targetOutput5 = "11:01 am"; +console.assert( + currentOutput5 === targetOutput5, + `current output: ${currentOutput5}, target output: ${targetOutput5}`, +); + console.log(formatAs12HourClock("08:01")); console.log(formatAs12HourClock("23:55")); console.log(formatAs12HourClock("25:01")); +console.log(formatAs12HourClock("00:01")); +console.log(formatAs12HourClock("11:01")); //Two patches //First hour input > 24, current algo is hours - 12 , e.g. 25-12 and print 13:00pm , rather than 1:00am (+1) From fe78cd5488fabe5c5531082e786de28a4217d463 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Wed, 30 Sep 2026 00:01:43 +0100 Subject: [PATCH 25/26] Refactor time formatting logic to correctly handle hours between 12 and 22, ensuring proper AM/PM representation --- Sprint-3/5-stretch-extend/format-time.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 7d40247cd..b7884afeb 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -7,8 +7,10 @@ function formatAs12HourClock(time) { const minutes = time.slice(-2); if (hours >= 24) { return `0${hours - 24}:${minutes} am +1`; - } else if (hours > 12) { + } else if (hours > 22) { return `${hours - 12}:${minutes} pm`; + } else if (hours > 12) { + return `0${hours - 12}:${minutes} pm`; } else if (hours > 9) { return `${hours}:${minutes} am`; } From fa9defbc2bef4839ef0e859001a7fd82e4f9daa1 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Thu, 1 Oct 2026 15:26:51 +0100 Subject: [PATCH 26/26] Fix time formatting to handle hours >= 24 and adjust AM/PM representation for edge cases (e,g, input HH = 00) --- Sprint-3/5-stretch-extend/format-time.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index b7884afeb..eac4c14da 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -5,15 +5,16 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); const minutes = time.slice(-2); - if (hours >= 24) { - return `0${hours - 24}:${minutes} am +1`; - } else if (hours > 22) { + if (hours > 22) { return `${hours - 12}:${minutes} pm`; } else if (hours > 12) { return `0${hours - 12}:${minutes} pm`; } else if (hours > 9) { return `${hours}:${minutes} am`; + } else if (hours < 1) { + return `12:${minutes} am`; } + return `0${hours}:${minutes} am`; } @@ -31,32 +32,25 @@ console.assert( `current output: ${currentOutput2}, target output: ${targetOutput2}`, ); -const currentOutput3 = formatAs12HourClock("25:00"); -const targetOutput3 = "01:00 am +1"; +const currentOutput3 = formatAs12HourClock("00:01"); +const targetOutput3 = "12:01 am"; console.assert( currentOutput3 === targetOutput3, `current output: ${currentOutput3}, target output: ${targetOutput3}`, ); -const currentOutput4 = formatAs12HourClock("00:01"); -const targetOutput4 = "00:01 am"; +const currentOutput4 = formatAs12HourClock("11:01"); +const targetOutput4 = "11:01 am"; console.assert( currentOutput4 === targetOutput4, `current output: ${currentOutput4}, target output: ${targetOutput4}`, ); -const currentOutput5 = formatAs12HourClock("11:01"); -const targetOutput5 = "11:01 am"; -console.assert( - currentOutput5 === targetOutput5, - `current output: ${currentOutput5}, target output: ${targetOutput5}`, -); - console.log(formatAs12HourClock("08:01")); console.log(formatAs12HourClock("23:55")); -console.log(formatAs12HourClock("25:01")); console.log(formatAs12HourClock("00:01")); console.log(formatAs12HourClock("11:01")); +console; //Two patches //First hour input > 24, current algo is hours - 12 , e.g. 25-12 and print 13:00pm , rather than 1:00am (+1)