From ce7f3df331c7326f6b06871f21ce6454fca4d516 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Wed, 24 Jun 2026 17:55:44 +0100 Subject: [PATCH 01/13] prep clock --- prep/clock.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 prep/clock.js diff --git a/prep/clock.js b/prep/clock.js new file mode 100644 index 000000000..1eebb1f5c --- /dev/null +++ b/prep/clock.js @@ -0,0 +1,10 @@ +function formatAs12HourClock(time) { + return `${time} am`; +} + +const currentOutput = formatAs12HourClock("08:00"); +const targetOutput = "08:00 am"; +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +); From 509aee5ccd8418660aa6e1624ebf66b76642cb63 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Wed, 24 Jun 2026 17:56:42 +0100 Subject: [PATCH 02/13] string for prep --- prep/string.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 prep/string.js diff --git a/prep/string.js b/prep/string.js new file mode 100644 index 000000000..a81195aee --- /dev/null +++ b/prep/string.js @@ -0,0 +1,6 @@ +function compareStrings(a, b) { + Number(a, b); + return a < b; +} + +console.log(compareStrings("1", "2")); From 1f4dc42abef9507cadaf4512f82cd0c7b602909e Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Wed, 24 Jun 2026 18:03:02 +0100 Subject: [PATCH 03/13] Sprint 2 Task 2 completed --- Sprint-2/1-key-errors/1.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..d74dbbcbf 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -2,9 +2,6 @@ // Why will an error occur when this program runs? // =============> write your prediction here - -// Try playing computer with the example to work out what is going on - function convertToPercentage(decimalNumber) { const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; @@ -14,7 +11,19 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); +// Try playing computer with the example to work out what is going on + // =============> write your explanation here +// Since the parameter and variable have the same name, decimalNumber, we will get an error as we can not declare a +// variable of the same name with in the functions local scope // 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 514c086fe67e0960ca8247e3843b1a8047072cba Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Wed, 24 Jun 2026 18:08:16 +0100 Subject: [PATCH 04/13] Sprint 2 Task 0 completed --- Sprint-2/1-key-errors/0.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..f19062918 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,8 +1,10 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here +// An error will be thrown because str has already been declared as the function's parameter. +// The function parameter and the let variable are both declared in the same function scope. -// call the function capitalise with a string input -// interpret the error message and figure out why an error is occurring +// 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)}`; @@ -10,4 +12,15 @@ function capitalise(str) { } // =============> write your explanation here +// The error occurs because str is already declared as the function's parameter, so it cannot be +// declared again using let inside the same scope. By changing the new variable's name to +// capitalisedStr, there is no longer a naming conflict and the code runs without any errors. + // =============> write your new code here + +function capitalise(str) { + let capitalisedStr = `${str[0].toUpperCase()}${str.slice(1)}`; + return capitalisedStr; +} + +console.log(capitalise("mmm")); From 29057036bf4134d0195d1a5b4904ff4368a2b6f2 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 25 Jun 2026 13:43:12 +0100 Subject: [PATCH 05/13] Sprint 2 Task 2 completed --- Sprint-2/1-key-errors/2.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..c88620b80 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -1,20 +1,25 @@ - // 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 +// =============> write your prediction of the error here: +// we have used a number instead of naming the parameter so we should get a syntax error function square(3) { - return num * num; + return num * num; } // =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here +// JavaScript read the number 3 as a number rather than the name of the parameter. +// Parameters must have valid names // Finally, correct the code to fix the problem // =============> write your new code here - +function square(num) { + return num * num; +} From e52b0969f97f461b5c0990e68bd9ad1d271afd7d Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 25 Jun 2026 15:13:57 +0100 Subject: [PATCH 06/13] Task 0 Folder 2 Complete --- Sprint-2/2-mandatory-debug/0.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..b3318ce02 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,6 +1,7 @@ // Predict and explain first... // =============> write your prediction here +// The function here is supposed to multiply both parameters by each other but the function multiply has no return so when the function is called by console.log it will return as undefined function multiply(a, b) { console.log(a * b); @@ -9,6 +10,14 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here +// The function here is supposed to multiply both parameters by each other but the function multiply has no return so when the function is called by console.log on line 10 it will return as undefined +// however this same function does say to output the result or a multiplied by b so the answer is outputted but not returned to line 10 and therefore we get undefined in that string // 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 329448e5319692a0de1a71b1b43e4a9bab616925 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 25 Jun 2026 19:43:30 +0100 Subject: [PATCH 07/13] sprint 2 task 2 exercise 1 completed --- Sprint-2/2-mandatory-debug/1.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..f2988932b 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,6 @@ // Predict and explain first... // =============> write your prediction here +// I expect that we will get an undefined output on line 10 since the function does not return anything function sum(a, b) { return; @@ -9,5 +10,13 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +// The function sum defines that a+b must be added together but before that return is used with no argument defined and we we exit the function immediately when it is called on line 10 the function returns to the string 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)}`); From 25fffb622aabfddbe739e7db785637f04df5dc01 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 25 Jun 2026 22:15:49 +0100 Subject: [PATCH 08/13] sprint two task 2 exercise 2 complete --- Sprint-2/2-mandatory-debug/2.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..32ac23a08 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -2,6 +2,7 @@ // Predict the output of the following code: // =============> Write your prediction here +// Since line 7 uses a const variable that can not be changed I would expect the last digit to be remain three since num has been assigned to be 103 const num = 103; @@ -14,11 +15,30 @@ 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 +// =============> 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 +// // Line 7 uses the const variable num which has been assigned the value 103 and the last digit of that number is 3. When the function getLastDigit is called it +// returns the last digit of num. Regardless of what number we use when calling the function it will always return 3 because the function has no parameter to read +// the arguments and always uses the value stored inside num instead. + // 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 + +// getLastDigit is not working properly because the function has no parameter to read the numbers used when it is called upon. Instead it always uses the const variable +// num which has been assigned the value 103 so it will always return the last digit of 3. From fa080a4dd89b6328367270d1d4f3eea8ed80abbf Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 25 Jun 2026 23:03:18 +0100 Subject: [PATCH 09/13] Sprint 2 Task 3 Exercise 1 Completed --- Sprint-2/3-mandatory-implement/1-bmi.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1..509d8a2ba 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,5 +15,10 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height -} \ No newline at end of file + let numWeight = Number(weight.slice(0, -2)); + let numHeight = Number(height.slice(0, -1)); + let BMI = numWeight / (numHeight * numHeight); + return Math.round(BMI * 10) / 10; +} + +console.log(`Your BMI is: ${calculateBMI("70kg", "1.83m")}`); From 6a4c5adc7efa3a851be65d20b4ce5bae3c60fb98 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 25 Jun 2026 23:31:52 +0100 Subject: [PATCH 10/13] Sprint 2 Task 3 Exercise 2 Completed --- Sprint-2/3-mandatory-implement/2-cases.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..badaa15ee 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,9 @@ // 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(string) { + return string.toUpperCase().replaceAll(" ", "_"); +} + +console.log(upperSnakeCase("i love cyf you guys are awesome!")); From 5dc9a636dc2e79459ed79b1868fe541478a888fe Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Fri, 26 Jun 2026 01:08:42 +0100 Subject: [PATCH 11/13] Sprint 2 Task 3 Exercise 3 --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..30b7c4356 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,25 @@ // 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 console.log(`£${pounds}.${pence}`); +} + +penceToPounds("399p"); +penceToPounds("580990p"); +penceToPounds("489302849032p"); From f9f9cdd3ccae539def6b68b78a8bb987d991d4ad Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Fri, 26 Jun 2026 17:34:44 +0100 Subject: [PATCH 12/13] Sprint 2 Task 4 Exercise time-format completed --- Sprint-2/4-mandatory-interpret/time-format.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 17127bc01..c5a20454b 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -15,24 +15,30 @@ 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 +// The pad function is called upon 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 +// num is = 0 // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// the return value is "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 value assigned is 1 this is because when the value 61 is passed into the formatTimeDisplay function it sends totalHours, +// remainingMinutes and remainingSeconds in that order to the pad function. Since we know the remainingSeconds is sent last +// and that 61 divided by 60 leaves us with a remainder of 1 we know 1 will be the last value assigned to num. // 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 return value will be "01" as when the value 1 is passed into the pad function it is converted into a string, which is "1" in this case, +// that string is then passed into a while loop which checks if the string is less than two characters and adds a "0" to the start of the string +// so "1" becomes "01" and is then returned. From fa6a305c2d6e9e88438b2f1c878ce6e0a16979b0 Mon Sep 17 00:00:00 2001 From: burhan-mustafa Date: Thu, 2 Jul 2026 15:28:02 +0100 Subject: [PATCH 13/13] removed prep folder for pull request --- prep/clock.js | 10 ---------- prep/string.js | 6 ------ 2 files changed, 16 deletions(-) delete mode 100644 prep/clock.js delete mode 100644 prep/string.js diff --git a/prep/clock.js b/prep/clock.js deleted file mode 100644 index 1eebb1f5c..000000000 --- a/prep/clock.js +++ /dev/null @@ -1,10 +0,0 @@ -function formatAs12HourClock(time) { - return `${time} am`; -} - -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); diff --git a/prep/string.js b/prep/string.js deleted file mode 100644 index a81195aee..000000000 --- a/prep/string.js +++ /dev/null @@ -1,6 +0,0 @@ -function compareStrings(a, b) { - Number(a, b); - return a < b; -} - -console.log(compareStrings("1", "2"));