From 49088faf2ec4bd763de924feb1fb5df5096e680c Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Fri, 18 Sep 2026 13:45:04 +0100 Subject: [PATCH 01/10] Answered 0.js and added new code --- Sprint-3/1-key-errors/0.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..f792ae1a5 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -4,10 +4,15 @@ // 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; -} +// function capitalise(str) { +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } // =============> write your explanation here +// The str has already been called so when its been set to the "let = str" it wont work as its already part of the function, so the name needs to change. // =============> write your new code here +function capitalise(str) { + let capitaliseStr = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} \ No newline at end of file From a0786f8707737f720880b91c4c31726faea27b2e Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 11:17:05 +0100 Subject: [PATCH 02/10] Answered teh question for 1.js and added in code to fix it. --- Sprint-3/1-key-errors/1.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..2716476a2 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -2,19 +2,31 @@ // Why will an error occur when this program runs? // =============> write your prediction here +// decimalNumber is part of the function so it cant be set with const decimalNumber, the name needs to be different. +// console.log(decimalNumber) causes an issue as well, decimalNumber is part of the function, it should request convertToPercentage for it to work. // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; +// function convertToPercentage(decimalNumber) { +// const decimalNumber = 0.5; +// const percentage = `${decimalNumber * 100}%`; - return percentage; -} +// return percentage; +// } -console.log(decimalNumber); +// console.log(decimalNumber); // =============> write your explanation here +// console.log(decimalNumber) will not work as decimalNumber is inside the function, +// and "const devimalNumber = 0.5" has already been called from teh function. You need to change the name or apply the value in the call on consol.log() + // Finally, correct the code to fix the problem // =============> write your new code here +function convertToPercentage(decimalNumber) { + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} + +console.log(convertToPercentage(0.5)); \ No newline at end of file From 8161a897bd4ac141a95281507b23cdc827324dc6 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 11:26:27 +0100 Subject: [PATCH 03/10] Answered the questions in 2.js and fixed the code required. --- Sprint-3/1-key-errors/2.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..404ffc077 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,28 @@ // Predict and explain first BEFORE you run any code... -// this function should square any number but instead we're going to get an error +// the function square(3) wont work as you cant have a number value for the function. // =============> write your prediction of the error here +// return num * num; wont work as -function square(3) { - return num * num; -} +// function square(3) { +// return num * num; +// } // =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here +// in the () is the parameter for the function and that cannot be a number as it has to be a name, following the same rules +// that are used so it can't start with a number. // Finally, correct the code to fix the problem // =============> write your new code here +function square(num) { + return num * num; +} +console.log(square(3)); \ No newline at end of file From ac68c4a1e0255c8da6c9d940ac9c12f58c21c04c Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 11:39:39 +0100 Subject: [PATCH 04/10] 2-mandatory-debug 0.js Answered questions and fixed code. --- Sprint-3/2-mandatory-debug/0.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..c6d19a366 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,23 @@ // Predict and explain first... // =============> write your prediction here +// syntax error as console.log(a, b) cant be part of the function. -function multiply(a, b) { - console.log(a * b); -} +// function multiply(a, b) { +// console.log(a * b); +// } -console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here +// I was wrong, it is showing the answer with console.log but giving undefined for the other as the function is incomplete. // Finally, correct the code to fix the problem // =============> write your new code here + +function multiply(a, b) { + let answer = (a * b); + return answer +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); \ No newline at end of file From 49726c9851b34357c57db3c4d2cda172f0416187 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 11:54:51 +0100 Subject: [PATCH 05/10] 2-mandatory-debug 1.js Answered questions and fixed code. --- Sprint-3/2-mandatory-debug/1.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..fcb3181d9 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,20 @@ // Predict and explain first... // =============> write your prediction here +// Going to show undefined -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)}`); // =============> write your explanation here +// the code is not doing the sum needed of a + b as they are just split by the ; , + // Finally, correct the code to fix the problem // =============> write your new code here + +function sum(a, b) { + return a + b; +} From bada0ad600b0e2e85513de241b0311a8d3723a2e Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 15:38:41 +0100 Subject: [PATCH 06/10] 2-mandatory-degub 2.js Answered questions and fixed the code as requested. --- Sprint-3/2-mandatory-debug/2.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..d7b324273 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,24 +1,41 @@ // Predict and explain first... -// Predict the output of the following code: +// Predict the output of the following code: // =============> Write your prediction here +// num is made to be 103, so every .log will have the answer being 3. +// function getLasDigit() has no parameter set, so the number set -const num = 103; +// const num = 103; -function getLastDigit() { - return num.toString().slice(-1); -} +// function getLastDigit() { +// return num.toString().slice(-1); +// } -console.log(`The last digit of 42 is ${getLastDigit(42)}`); -console.log(`The last digit of 105 is ${getLastDigit(105)}`); -console.log(`The last digit of 806 is ${getLastDigit(806)}`); +// console.log(`The last digit of 42 is ${getLastDigit(42)}`); +// console.log(`The last digit of 105 is ${getLastDigit(105)}`); +// console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction // =============> write the output here +// 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 +// const num = 103 is making it that num is always 103, also function getLastDigit() has no parameter set. +// This makes it that the value from teh console.log() wont be used. + // Finally, correct the code to fix the problem // =============> write your new code here +function getLastDigit(num) { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); + // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 0466037d66c3937a4090b2e0d3a7179c476c37e4 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 15:49:27 +0100 Subject: [PATCH 07/10] 3-mandatory-implement - 1-bmi.js Added in the code as requested. --- Sprint-3/3-mandatory-implement/1-bmi.js | 6 +++++- 1 file changed, 5 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..fbef86913 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,5 +15,9 @@ // 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 + let squaring=height * height; + return (70 / squaring).toFixed(2); + } + +console.log(calculateBMI(100, 1.85)) From 29509c21b58e3c2b5a8c007ca262446ad7163357 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 15:59:30 +0100 Subject: [PATCH 08/10] 3-mandatory-implement - s-cases.js completed code as requested. --- Sprint-3/3-mandatory-implement/2-cases.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..8250dc4c6 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,10 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase + +function upperSnakeCase(text) { + let upperCase = text.toUpperCase(""); + return upperCase.replaceAll(" ", "_"); +} + +console.log(upperSnakeCase("Hello World")) \ No newline at end of file From 82e81ed33c7203d4accb242725516ec351e18185 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 19 Sep 2026 16:29:06 +0100 Subject: [PATCH 09/10] 3-mandatory-implement - 3-to-pounds.js Copied code from Sprint-1 3-to-pounds.js and fixed it to run multiple values. --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 45 +++++++++++++++++++ 1 file changed, 45 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..6939df6b7 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,48 @@ // 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 + +// const penceString = "399p"; + +// 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"); + +// console.log(`£${pounds}.${pence}`); + +function poundsAndPence(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(poundsAndPence("399p")) +console.log(poundsAndPence("599p")) +console.log(poundsAndPence("1796p")) +console.log(poundsAndPence("562p")) +console.log(poundsAndPence("2p")) +// const penceString = "399p"; \ No newline at end of file From 4f61c5c45fd31b49b2979d867bc21c351f0ff006 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 22 Sep 2026 16:59:17 +0100 Subject: [PATCH 10/10] Answered questions relating to time-format.js used console.log to help understand how the function works. --- Sprint-3/4-mandatory-interpret/time-format.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..3f22b377d 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,20 +1,29 @@ +console.log("entered data") function pad(num) { + console.log("pad has been called: Num is", num); let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; } + console.log("numString: ", numString); return numString; } function formatTimeDisplay(seconds) { + console.log("entered formatTimeDisplay"); const remainingSeconds = seconds % 60; + console.log("remainingSeconds: ", remainingSeconds); const totalMinutes = (seconds - remainingSeconds) / 60; + console.log("totalMinutes: ", totalMinutes); const remainingMinutes = totalMinutes % 60; + console.log("remainingMinutes: ", remainingMinutes); const totalHours = (totalMinutes - remainingMinutes) / 60; + console.log("totalHours: ", totalHours); + 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 @@ -22,17 +31,22 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// Pad is being called 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 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 value given is the remainder after being used in remainingMinutes section of the code // 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, after going through pad it ensures that there is two 00 if there is no value left, with just 1 it adds one 0 to the front of 1.