From 0f33d19923d2d6ea09823f6784814a0860ada3e1 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 12 Feb 2026 19:33:51 +0000 Subject: [PATCH 01/18] Updating the solution with correct code --- Sprint-2/1-key-errors/0.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..feaf687c2 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,13 +1,25 @@ // Predict and explain first... // =============> write your prediction here +// I predict that the code will throw an error due to the fact that the function redeclares the +// the str using let str. This is not allowed as it is already defined as a parameter. // 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; +//} + +//console.log(capitalise("hello")); +// =============> write your explanation here +// The error occures due to the fact that str is already declared as a function parameter. +// Using let str inside the function tries to redeclare the same variable, which is causing a syntaxError for Javascript. + +// =============> write your new code here +// =============> write your new code here 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 +console.log(capitalise("hello")); From ce226e08672d5bfa49b1d662c7992f5e0aa34cb0 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 12 Feb 2026 19:34:15 +0000 Subject: [PATCH 02/18] Removing incorrect commented out solution --- Sprint-2/1-key-errors/0.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index feaf687c2..b90d09822 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -6,10 +6,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; -//} //console.log(capitalise("hello")); // =============> write your explanation here From d2f7e65832873e1627ebeb7decf0d63aa6a88853 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 12 Feb 2026 20:16:07 +0000 Subject: [PATCH 03/18] committing the actions for 1.js --- Sprint-2/1-key-errors/1.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..200ccaa4d 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -2,11 +2,14 @@ // Why will an error occur when this program runs? // =============> write your prediction here +// My prediction is that this will solution will fail due to the fact that the percentage declaration is being declared twice. +// The second issue is the decimalNumber is being logged to the console, but this is parameter for convertToPercentage. +// So to call the function accurately we need to call convertToPercentage not decimalNumber. // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; + const percentage = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; @@ -15,6 +18,14 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // =============> write your explanation here +// The function convertToPercentage takes a decimal number as parameter. +// It multiplies the number by 100 and converts it into a string with a "%" symbol. +// The corrected version removes the duplicate declaration and calls the function properly. // 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 7bd2bfd305fc17c6cd695876067dbdd697774d48 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 12 Feb 2026 20:18:26 +0000 Subject: [PATCH 04/18] replacing the code to prevent merge issues --- Sprint-2/1-key-errors/0.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index b90d09822..872ff72bc 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -6,6 +6,10 @@ // 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; +} //console.log(capitalise("hello")); // =============> write your explanation here From 1e51e89b56fff9595196ad33998eba0edbfe22c4 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Thu, 12 Feb 2026 20:25:38 +0000 Subject: [PATCH 05/18] Replacing the missing code to prevent merge issues --- Sprint-2/1-key-errors/1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 200ccaa4d..2cd06cad0 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -2,14 +2,14 @@ // Why will an error occur when this program runs? // =============> write your prediction here -// My prediction is that this will solution will fail due to the fact that the percentage declaration is being declared twice. +// My prediction is that this will solution will fail due to the fact that the decimalNumber is being declared twice. // The second issue is the decimalNumber is being logged to the console, but this is parameter for convertToPercentage. // So to call the function accurately we need to call convertToPercentage not decimalNumber. // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const percentage = 0.5; + const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; From 8435f7cfa26e221ec8f0697d7a47734ccbabf03d Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Fri, 13 Feb 2026 07:57:20 +0000 Subject: [PATCH 06/18] Committing the actions for 2.js --- Sprint-2/1-key-errors/2.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..8e19b6620 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -4,17 +4,34 @@ // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here +// This function will cause a syntax error due to the fact that the parameter should be variable name, not a literal value. +// The second issue is that "num" is used inside the function however it is not defined anywhere. function square(3) { return num * num; } // =============> write the error message here +// SyntaxError: Unexpected number +// at internalCompileFunction (node:internal/vm:76:18) +// at wrapSafe (node:internal/modules/cjs/loader:1283:20) +// at Module._compile (node:internal/modules/cjs/loader:1328:27) +// at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) +// at Module.load (node:internal/modules/cjs/loader:1203:32) +// at Module._load (node:internal/modules/cjs/loader:1019:12) +// at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) +// at node:internal/main/run_main_module:28:49 // =============> explain this error message here +// This error message means that JS expects a parameter name within the function. +// The second error message is "num" is not declared. // Finally, correct the code to fix the problem // =============> write your new code here +function square(num) { + return num * num; +} +console.log(square(3)); From 47bd57df8a9d0cfe136a63bc3907dcceda36484b Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Fri, 13 Feb 2026 08:04:41 +0000 Subject: [PATCH 07/18] Committing the actions for 0.js --- Sprint-2/2-mandatory-debug/0.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..2cd730fb7 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,14 +1,22 @@ // Predict and explain first... // =============> write your prediction here +// The function multiply(a, b) logs the result within the function but does not return anything. 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 +// Console.log() will print something. +// Return gives a value back to the caller - the function currently will print the result but does not return it. // 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 5f4ae713724182c0e47afe419545db0a037357d7 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Fri, 13 Feb 2026 08:12:51 +0000 Subject: [PATCH 08/18] Committing the actions for 1.js --- Sprint-2/2-mandatory-debug/1.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..723346c6b 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,13 +1,24 @@ -// Predict and explain first... -// =============> write your prediction here + // Predict and explain first... + // =============> write your prediction here + // I predict that the function will not return undefined. + // This is due to the fact that the return statement is on its own line, therefore trying to do the addition will not work as the code is not read. -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 -// Finally, correct the code to fix the problem -// =============> write your new code here + // =============> write your explanation here + // The return statement is written on its own line, therefore JS automatically inserts a semicolon after the return. + // This means that the function exits immediately and returns undefined. + // The expression a + b; is not executed. + + // 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 901a010f29d36bf5e2e6e22b5449de9a07ea97f1 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Fri, 13 Feb 2026 08:23:47 +0000 Subject: [PATCH 09/18] Committing the actions for 2.js --- Sprint-2/2-mandatory-debug/2.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..2cd0c49bd 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -2,6 +2,8 @@ // Predict the output of the following code: // =============> Write your prediction here +// I predict that the three console.log messages will always output 3. +// This is due to the fact that the const num is defined as 103 and the program will always use that global value as the source of truth. const num = 103; @@ -9,16 +11,32 @@ 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 +// The global value that is defined outside of the function is used as the source of truth. +// Therefore when the program executes the line return num.toString().slice(-1); it always considers the global value. +// The console.log ignores the values. + // 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 2d4a76964c5f97addc144ac093df6ab8c924bcba Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Fri, 13 Feb 2026 08:43:14 +0000 Subject: [PATCH 10/18] Committing the actions for 1-bmi.js --- Sprint-2/3-mandatory-implement/1-bmi.js | 10 ++++++++-- 1 file changed, 8 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..9ecdd096b 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -14,6 +14,12 @@ // Then when we call this function with the weight and height // It should return their Body Mass Index to 1 decimal place +// solution 1 function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height -} \ No newline at end of file + const bmi = weight / (height ** 2); + return Number(bmi.toFixed(1)); +} +console.log(`My BMI is: ${calculateBMI(55, 1.3)}`) + +// solution 2 +// To make this program fit for real world use, I would implement a conversion for various metrics used for height and weight. \ No newline at end of file From 9256e9d5091ae91f3f38684141241572630108ab Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 15 Feb 2026 21:09:35 +0000 Subject: [PATCH 11/18] committing the actions for 2-cases.js --- Sprint-2/3-mandatory-implement/2-cases.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..4a71abb72 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,8 @@ // 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 +// Solution +function toUpperSnakeCase(str) { + return str.toUpperCase().replaceAll(" ","_"); +} +console.log(ToUpperSnakeCase("hello there")); \ No newline at end of file From 68ae18398104c732c6f9460674596478a4562e4d Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 15 Feb 2026 21:32:58 +0000 Subject: [PATCH 12/18] committing the actions for 3-to-pounds.js --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 14 ++++++++++++++ 1 file changed, 14 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..614702682 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,17 @@ // 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 + +//Solution: +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("399p")); +console.log(toPounds("45p")); +console.log(toPounds("5p")); +console.log(toPounds("1200p")); \ No newline at end of file From 2daa64934f067eae9d5c901c8f0a0441c3e5b10a Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 16 Feb 2026 20:03:11 +0000 Subject: [PATCH 13/18] Committing the answer to a) for 4-mandatory-interpret --- Sprint-2/4-mandatory-interpret/time-format.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8..e8245bcde 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -18,6 +18,7 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// Pad will be called three times (for hours, minutes and seconds) // Call formatTimeDisplay with an input of 61, now answer the following: From 011292ba5fff5ce9e769463f28e4213e1ee26e5b Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 16 Feb 2026 20:07:33 +0000 Subject: [PATCH 14/18] Committing the ans to b) for 4-mandatory-interpret --- Sprint-2/4-mandatory-interpret/time-format.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index e8245bcde..2e56a947b 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -11,6 +11,8 @@ 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 @@ -24,6 +26,7 @@ function formatTimeDisplay(seconds) { // b) What is the value assigned to num when pad is called for the first time? // =============> write your answer here +// The value assigned to num for the first time that it is called is 0 (totalHours = 0) // c) What is the return value of pad is called for the first time? // =============> write your answer here From 518027244a10096158589edf9eca0c510727d6da Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 16 Feb 2026 20:08:58 +0000 Subject: [PATCH 15/18] Committing the ans to c) for 4-mandatory interpret --- Sprint-2/4-mandatory-interpret/time-format.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 2e56a947b..d42977dad 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -30,6 +30,7 @@ console.log(formatTimeDisplay(61)); // c) What is the return value of pad is called for the first time? // =============> write your answer here +// The return value of pad for its first call 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 From 54b451c47648ba395537b47a07c6c4af5921e3a4 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 16 Feb 2026 20:13:27 +0000 Subject: [PATCH 16/18] Committing the ans to d) for 4-mandatory-interpret --- Sprint-2/4-mandatory-interpret/time-format.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index d42977dad..42cb43e20 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -34,6 +34,9 @@ console.log(formatTimeDisplay(61)); // 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 is 1, when formatTimeDisplay(61) runs: 61 seconds = 1 minute and 1 second +// remainingSeconds = 61 % 60 = 1 +// The last call to pad is pad(remainingSeconds), so num receives 1 // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer // =============> write your answer here From a959ad7a7a12e9aa310a84a64628ee8267263f86 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 16 Feb 2026 20:15:11 +0000 Subject: [PATCH 17/18] Committing the ans to e) for 4-mandatory-interpret --- Sprint-2/4-mandatory-interpret/time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 42cb43e20..2cc6bcbd2 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -40,3 +40,5 @@ console.log(formatTimeDisplay(61)); // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer // =============> write your answer here +// The return value is "01" - pad converts the number to a string and ensures it has at least 2 digits using padStart(2, "0") +// Since "1" has only one digit, a leading zero is added so the value is then "01" From 9e23607196f25ce6312fcc4499cafda5032384d4 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 23 Feb 2026 21:22:57 +0000 Subject: [PATCH 18/18] Correcting the variable name within console.log --- Sprint-2/3-mandatory-implement/2-cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 4a71abb72..64c3ba4f0 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -18,4 +18,4 @@ function toUpperSnakeCase(str) { return str.toUpperCase().replaceAll(" ","_"); } -console.log(ToUpperSnakeCase("hello there")); \ No newline at end of file +console.log(toUpperSnakeCase("hello there")); \ No newline at end of file