From 0921c642353c3797f0548d044af2e6c6ad28de29 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 19:45:49 +0100 Subject: [PATCH 01/14] fix error 0 --- Sprint-3/1-key-errors/0.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..22db068ce 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,17 @@ // Predict and explain first... -// =============> write your prediction here +// =============>The function will return capital S because the first letter of the str variable was capitalised with the toUpperCase method // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring +// The str identifier has already been declared in the function parameter and cannot be declared anywhere else inside the function as a variable + +// =============> write your explanation here +// When a parameter is declared in a function, it causes an Error if it is declared inside the function as a variable, either you change the name used for the instructions or remove let +// =============> write your new code here function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; + str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } -// =============> write your explanation here -// =============> write your new code here +console.log(capitalise("hello")); \ No newline at end of file From cfa3c0e40b436f70d92557a26e3dcd0210dc9c71 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 19:48:10 +0100 Subject: [PATCH 02/14] resolve error 0 --- Sprint-3/1-key-errors/0.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 22db068ce..b001be479 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -3,7 +3,13 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -// The str identifier has already been declared in the function parameter and cannot be declared anywhere else inside the function as a variable +// The str identifier has already been declared in the function parameter and cannot be declared anywhere else inside the function as a variable + +function capitalise(str) { + let str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} + // =============> write your explanation here // When a parameter is declared in a function, it causes an Error if it is declared inside the function as a variable, either you change the name used for the instructions or remove let From 063ef8dd01cb8a8598046cc29632fa399ff77a10 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 20:12:59 +0100 Subject: [PATCH 03/14] fix error 1 --- Sprint-3/1-key-errors/1.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..7b9a7f9f1 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,7 +1,7 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// because the decimanlNumber variable has already been declared and you cant declare it twice, also the parameter needs to not be tied to any value so it works as intended // Try playing computer with the example to work out what is going on @@ -15,6 +15,14 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // =============> write your explanation here +// decimalNumber creates a variable in the function scope, then const decimalNumber tries to create a variable with the same name in that same scope, then it hits a Syntax error. Then the program stops running // 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 4c2400a2bdeba7ed73be16637f8787a04cb6565d Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 20:20:11 +0100 Subject: [PATCH 04/14] Fix error 2 --- Sprint-3/1-key-errors/2.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..e7bb68f00 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -3,18 +3,20 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> Because the parameter needs to possess a name, i believe this will throw an error function square(3) { return num * num; } -// =============> write the error message here +// =============> SyntaxError: Unexpected number -// =============> explain this error message here +// =============> Because a parameter is a placeholder name for the function, it should receive a value when the function is called, it cant be 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)); From 0c19af25a871e134f973d1c7c1536a59bebcd197 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 20:32:33 +0100 Subject: [PATCH 05/14] fix debug 0 --- Sprint-3/2-mandatory-debug/0.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..f03823b6e 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... -// =============> write your prediction here +// =============> The function instructions will work but because there is no return statement it will be undefined function multiply(a, b) { console.log(a * b); @@ -8,7 +8,11 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> Because a return statement will return that value back to the code, it will send it back to who called the function this does not mean the human will see it in the log, console.log is used to show the result to the reader. // 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)}`); \ No newline at end of file From da1d1020997942580e3ac6313e9cdc98d4247b8c Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 20:45:26 +0100 Subject: [PATCH 06/14] fix debug 1 --- Sprint-3/2-mandatory-debug/1.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..ca13b4461 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> This will not work because the a + b statement should have been after return, but return has a semicolon after it which stops the function an returns nothing function sum(a, b) { return; @@ -8,6 +8,12 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> Because return and a+b are not on the same line, the line after return is never reached, and would be considered dead code and therefore the console logs argument as undefined + // Finally, correct the code to fix the problem -// =============> write your new code here + +function sum(a, b) { + return a + b; +} + +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); \ No newline at end of file From b1699d27785be9a5d8eb90dcbf6f85eec5fe75db Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 20:46:59 +0100 Subject: [PATCH 07/14] Debug 1 formatting --- Sprint-3/2-mandatory-debug/1.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index ca13b4461..ff311ccd4 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -16,4 +16,5 @@ 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 b63b5023ca1c6deaf4b4242da2251f991f6b8860 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 21:12:24 +0100 Subject: [PATCH 08/14] debug exercise 2 --- Sprint-3/2-mandatory-debug/2.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..219370657 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,7 +1,7 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> This function aims to return the number as a string using the toString method, and returns the last index in the string using the slice method with -1. the issue is that the number variable was declared outside the function as const, so the last digit will always be 3 const num = 103; @@ -15,10 +15,28 @@ 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 +// Because the num variable was declared outside the function which returns num with the string methods accessed with it. The function also has no parameter to receive the value passed in the function. + // 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 + +// The reason it was not working properly is because there was no parameter that can receive the value passed in the function, and so when the function is called it defaults to the num const variable in the global scope \ No newline at end of file From 94ae80215a6f217db239b275e56872d7ea5df172 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 21:24:17 +0100 Subject: [PATCH 09/14] implement exercise 1 --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..d8d415c81 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,5 +15,7 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { + return weight / (height*2); // return the BMI of someone based off their weight and height } +console.log(`The BMI of Jacob based on his weight and height is ${calculateBMI(75,1.70 )}`); \ No newline at end of file From fd98e3432526b880b2fbd2232f52932e66da9666 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 21:26:23 +0100 Subject: [PATCH 10/14] fix implement 1 --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index d8d415c81..19e24319f 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,7 +15,7 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return weight / (height*2); + return weight / (height**2); // return the BMI of someone based off their weight and height } console.log(`The BMI of Jacob based on his weight and height is ${calculateBMI(75,1.70 )}`); \ No newline at end of file From 5618f733ff679712bbfa4aa5ed8e6d1919db1aba Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 21:31:18 +0100 Subject: [PATCH 11/14] shorten result implement 1 --- 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 19e24319f..876ba24e0 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,7 +15,8 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return weight / (height**2); + const bmi = weight / (height**2); + return bmi.toFixed(1) // return the BMI of someone based off their weight and height } console.log(`The BMI of Jacob based on his weight and height is ${calculateBMI(75,1.70 )}`); \ No newline at end of file From 45542f2fec0c7df0e4971a82dd68527d7b0d416d Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 21:40:41 +0100 Subject: [PATCH 12/14] implement exercise 2 --- Sprint-3/3-mandatory-implement/2-cases.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..e839f9721 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,11 @@ // 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(cap) { + + return cap.toUpperCase().replaceAll(" ", "_"); +} + +console.log(toUpperSnakeCase("hello there")); +console.log(toUpperSnakeCase("lord of the rings")); \ No newline at end of file From 664a42efca596a00ff2db2ac6c5607668d076f9f Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sat, 10 Oct 2026 21:57:42 +0100 Subject: [PATCH 13/14] implement exercise 3 --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 25 +++++++++++++++++++ 1 file changed, 25 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..1a64eeae6 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,28 @@ // 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("790p")); +console.log(toPounds("70p")); +console.log(toPounds("8950p")); +console.log(toPounds("6p")); \ No newline at end of file From b96fd37381b7ce68e0efdfade3b9791e7a839d70 Mon Sep 17 00:00:00 2001 From: Ahmed Elmahmoudi Date: Sun, 11 Oct 2026 02:12:11 +0100 Subject: [PATCH 14/14] interpret exercise 4 time format --- Sprint-3/4-mandatory-interpret/time-format.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..5643d605f 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -21,18 +21,18 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> It will be called 3 times in template lateral // 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 because template laterals run from left to right and pad(totalHours) is 0 // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here +// =============> it returns "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 +// =============> The last pad called is pad(remainingSeconds) which is 61 % 60 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 +// =============> it returns "01" because numString is "1" with length of 1 which is less than 2, the loop adds 0 to the front so its 01