From 358846c64a87cb0110ea73e3d810c0fd7ca5ffa4 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Thu, 24 Sep 2026 22:21:10 +0200 Subject: [PATCH 01/14] add .gitattributes to normalise line endings --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..176a458f9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto From e52f37abb3636bdb5a4252122e90ca12be91e741 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 00:07:56 +0200 Subject: [PATCH 02/14] fix duplicate declaration in sprint 3 key error 0 --- Sprint-3/1-key-errors/0.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..34bce0941 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,12 @@ // Predict and explain first... -// =============> write your prediction here + // Prediction: I think the code will have a SyntaxError because 'str' is declared twice. // 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; +return `${str[0].toUpperCase()}${str.slice(1)}`; } -// =============> write your explanation here -// =============> write your new code here + // Explanation: The function already has something called str. You can't make a second thing with the same name inside the same function + // New code: removed the 'let str =' line and returned the expression directly. From 6d602d85a1e3d5233c19386d46b85198773e6710 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 01:41:56 +0200 Subject: [PATCH 03/14] fix duplicate declaration and print call in sprint 3 key error 1 --- Sprint-3/1-key-errors/1.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..761eb9e07 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,20 +1,22 @@ // Predict and explain first... -// Why will an error occur when this program runs? -// =============> write your prediction here - +// Why will an error occur when this program runs + // When this program runs there will be an identifier SyntaxError because 'decimalNumber' has already been declared + // Also the output will print a decimal since it says console.log(decimalNumber); // 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); +console.log(convertToPercentage(0.5)); -// =============> write your explanation here +// 'decimalNumber' is already declared in two different areas in the same function which JavaScript does not allow. +// 'decimalNumber' is only useful inside the function, so it will give an error of not knowing what decimalNumber is, +// even if it succeeds it will give the wrong output since what we are looking for is the percentage. // Finally, correct the code to fix the problem -// =============> write your new code here +// New code: 1. Removed the duplicate `const decimalNumber = 0.5;` line. +// 2. Changed the console.log to call the function and print the result. From 03d224d438e6893218a24e8a09a4be68b0cdb4ed Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 02:12:52 +0200 Subject: [PATCH 04/14] fix parameter name in sprint 3 key error 2 --- Sprint-3/1-key-errors/2.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..45c6fece3 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -3,18 +3,19 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// Prediction: there is going to be an error because there is a number in the parameter -function square(3) { +function square(num) { return num * num; } +console.log(square(5)); +// it showed SyntaxError: Unexpected number -// =============> write the error message here - -// =============> explain this error message here +// the parameter of a function must be a name /identifier, not a number. +// JavaScript expected a word as a parameter but fond a number instead hence the SyntaxError. // Finally, correct the code to fix the problem -// =============> write your new code here +// New code : replaced the parameter with a valid identifier From bf759e3cf077d5264a2451bbcb6168fcee10cbd0 Mon Sep 17 00:00:00 2001 From: Vaidah Simenti Date: Fri, 25 Sep 2026 02:16:11 +0200 Subject: [PATCH 05/14] save 2 unsaved files --- Sprint-3/1-key-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 761eb9e07..d8526afa4 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -19,4 +19,4 @@ console.log(convertToPercentage(0.5)); // Finally, correct the code to fix the problem // New code: 1. Removed the duplicate `const decimalNumber = 0.5;` line. -// 2. Changed the console.log to call the function and print the result. +// 2. Changed the console.log to call the function and print the result. From c937b63c7fd8881e0968308b2cc86963ac229711 Mon Sep 17 00:00:00 2001 From: Vaidah Simenti Date: Fri, 25 Sep 2026 02:17:57 +0200 Subject: [PATCH 06/14] save 2.js --- Sprint-3/1-key-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 45c6fece3..055fe4632 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -8,7 +8,7 @@ function square(num) { return num * num; } -console.log(square(5)); + // it showed SyntaxError: Unexpected number // the parameter of a function must be a name /identifier, not a number. From 63539e9fcfcd6b16d18741c8e6bbf71b040a33e6 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 17:14:23 +0200 Subject: [PATCH 07/14] change console.log to return in sprint 3 key error 3 --- Sprint-3/2-mandatory-debug/0.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..2509f2bfb 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,15 @@ // Predict and explain first... -// =============> write your prediction here +// Prediction:I think it will print 320, but the template string might not show the right result, but will return nothing. 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 +// because console.log will print whatever it is given . +// the function has no return statement, so when we run the code it will say undefined because there is nothing to give back. // Finally, correct the code to fix the problem // =============> write your new code here From 9f7a9a0a3ad7a79b48ee50508f7124d7fd51da05 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 17:45:10 +0200 Subject: [PATCH 08/14] fix early return --- Sprint-3/2-mandatory-debug/1.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..2090aada8 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,13 @@ // Predict and explain first... -// =============> write your prediction here +// =====> It will not run and will come out as undefined function sum(a, b) { - return; - a + b; + return a + b; } console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here -// Finally, correct the code to fix the problem +// =====> There is a semicolon right after return, which tells it to stop there, +// so basically anything that comes after that will not run hence the undefined result. +// Finally, correct the code to fix the problem will be to remove the semicolon. // =============> write your new code here From 375a08178d55614f2fbc62b19dcc720b755bddd9 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 18:40:45 +0200 Subject: [PATCH 09/14] add parameter to getLastDigit --- Sprint-3/2-mandatory-debug/2.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..8c1d2766a 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 +// =============> I think the result prints will always be 3 as num will always be 103. const num = 103; @@ -14,11 +14,23 @@ 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 +// =============> because the code is using the outer variable num which is always 103. +// so every call is returning the last digit of 103. // 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 +// because there was no parameter so the function has no way of receiving the numbers. so adding a parameter fixes it. \ No newline at end of file From bbe2a4e8b8f2a93d0bc6497ae979fb88705ec376 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 19:05:07 +0200 Subject: [PATCH 10/14] implement calculateBMI --- Sprint-3/3-mandatory-implement/1-bmi.js | 4 +++- 1 file changed, 3 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..6fcfc1731 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 the BMI of someone based off their weight and height + return (weight / (height*height)). toFixed(1); } + +console.log(calculateBMI(70, 1.73)); From 46db88c03c0851e550db3d2d36ddc4a72939c746 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 19:36:31 +0200 Subject: [PATCH 11/14] implement toUpperSnakeCase --- Sprint-3/3-mandatory-implement/2-cases.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..75276cf8c 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/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 toUpperSnakeCase(str) { + return str.toUpperCase().replaceAll(" ", "_"); +} + +console.log(toUpperSnakeCase("hello there")); // "HELLO_THERE" +console.log(toUpperSnakeCase("lord of the rings")); // "LORD_OF_THE_RINGS" \ No newline at end of file From 0cf04ad5d509d002437b5b0c99034a967b04b631 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 20:46:28 +0200 Subject: [PATCH 12/14] implement toPounds --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 10 ++++++++++ 1 file changed, 10 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..c123214d2 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,13 @@ // 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 pence = Number(penceString.replace("p", "")); + return `£${(pence / 100).toFixed(2)}`; +} + +console.log(toPounds("399p")); +console.log(toPounds("5p")); +console.log(toPounds("50p")); +console.log(toPounds("1250p")); +console.log(toPounds("0p")); \ No newline at end of file From 6789819b305ac44300939e4eb973137678594313 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 21:42:38 +0200 Subject: [PATCH 13/14] answer interpret questions --- Sprint-3/4-mandatory-interpret/time-format.js | 11 ++++++----- 1 file changed, 6 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..6216bc5aa 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -21,18 +21,19 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> 3 times because the return statement has three pad() calls in it. Hrs, Mins, Secs. // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> The first pad call pad(totalHours) worked out to 0 // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here +// =============> The value is 00, add another because every pad wants 2 digits. // 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 call receives 1 as its num because last call called is pad(remainingSeconds) which is calculated as seconds % 60. +// and with the seconds being 61, that's 61 % 60 giving 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 +// =============> The call is pad(1) and the pad adds a 0 to make the string 2 digits From 8e26037192a9f4969877e69478e2affe81643c27 Mon Sep 17 00:00:00 2001 From: Vaidah Date: Fri, 25 Sep 2026 22:48:22 +0200 Subject: [PATCH 14/14] remove .gitattributes --- .gitattributes | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 176a458f9..000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto