From 3bdfb602a0b3ca08a4dc75f6cadf2d162297de33 Mon Sep 17 00:00:00 2001 From: abmhts Date: Wed, 16 Sep 2026 16:14:32 +0100 Subject: [PATCH 01/17] Convert price strings to numbers before calculating --- .../3-mandatory-interpret/1-percentage-change.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..e2b19128e 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,21 @@ console.log(`The percentage change is ${percentageChange}`); // Read the code and then answer the questions below // a) How many function calls are there in this file? Write down all the lines where a function call is made - + 4 function calls + -Number(carPrice.replaceAll(",", "")) + -replaceAll(",", "") + -Number(priceAfterOneYear.replaceAll("," "")) + -replaceAll("," "") // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? - + -Line 5 + -missing ) after argument list + -why: replaceAll() needs two arguments separated by a comma. + -fix: by adding comma replaceAll(",", "") // c) Identify all the lines that are variable reassignment statements + line 4 and 5 // d) Identify all the lines that are variable declarations - + line 1,2,7 and 8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + -First removing the comma "10,000" + -Second convert string into number 10000 \ No newline at end of file From 15e3b83f6079339faecd9361397779693daae5d0 Mon Sep 17 00:00:00 2001 From: abmhts Date: Mon, 21 Sep 2026 12:54:10 +0100 Subject: [PATCH 02/17] explaining error msg and fix the code --- Sprint-3/1-key-errors/0.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..4220f10e5 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,19 @@ // Predict and explain first... // =============> write your prediction here - + //- we expect a syntaxerror because "str" is already declared as function parameter and again as a variable within the same function scope. // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring + //"Error: SyntaxError: Identifier 'str' has already been declared" why: because "str" declared twice. -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 + //- I changed the variable name to "strg" to avoid the error. // =============> write your new code here +function capitalise(str) { + let strg = `${str[0].toUpperCase()}${str.slice(1)}`; + return strg; +} \ No newline at end of file From a44bb25215402dafbad3c5a09a07aa78926a33d8 Mon Sep 17 00:00:00 2001 From: abmhts Date: Mon, 21 Sep 2026 17:33:39 +0100 Subject: [PATCH 03/17] Explaining the error, prediction, and fix --- Sprint-3/1-key-errors/1.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..ed809e14c 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,20 +1,30 @@ // Predict and explain first... // Why will an error occur when this program runs? + //- variable name "decimalNumber" declared twice in the same function. one as function parameter and again as a const in the same function. // =============> write your prediction here - + //- SyntaxError because "decimalNumber" declared twice. // 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 - + //- "decimalNumber" is already provided as a parameter to the function, but I don't need a parameter because I'm creating the value "0.5" inside the function. So I removed the parameter. I also need to call the function with convertToPercentage() instead of console.log(decimalNumber) because "decimalNumber" only exists inside the function. // Finally, correct the code to fix the problem // =============> write your new code here + +function convertToPercentage() { + const decimalNumber = 0.5; + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} + +console.log(convertToPercentage()); From c5a6226f3b9d99084789d370e6142cce5ef93075 Mon Sep 17 00:00:00 2001 From: abmhts Date: Mon, 21 Sep 2026 18:15:04 +0100 Subject: [PATCH 04/17] fix function square code error --- Sprint-3/1-key-errors/2.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..afeb54766 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,27 @@ // Predict and explain first BEFORE you run any code... - + // this function should square any number but instead we're going to get an error + //we are giving a value for the input instead of name that can hold different values. // =============> write your prediction of the error here + //syntaxerror related to the function input "(3)" -function square(3) { - return num * num; -} +// function square(3) { +// return num * num; +// } // =============> write the error message here // =============> explain this error message here - + // we gave a placeholder for the function instead of value that can't be changed. // 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 052c090be62aa4d343b4c6124c9b1d2f750e5d67 Mon Sep 17 00:00:00 2001 From: abmhts Date: Mon, 21 Sep 2026 20:30:39 +0100 Subject: [PATCH 05/17] Added return statement to fix the error --- Sprint-3/2-mandatory-debug/0.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..d28dd080d 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,21 @@ // Predict and explain first... - // =============> write your prediction here + //- "a and b" are defined as parameters and receive 10 and 32. The function calculates and logs 320, but it doesn't return the value. Because there is no return, the function call evaluates to undefined. -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 + //- Added a return statement so the function returns the result to the function call. The console.log() is just printing 320 and function doesn't give 320 back and thats why "${multiply(10, 32)}" gets undefined. // 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 d6eb93e122d55fb6ee3f01d044dea0605ae5211b Mon Sep 17 00:00:00 2001 From: abmhts Date: Mon, 21 Sep 2026 20:44:24 +0100 Subject: [PATCH 06/17] fix return statement --- Sprint-3/2-mandatory-debug/1.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..274620bdc 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,21 @@ // Predict and explain first... // =============> write your prediction here + //- return statement in this case stops before it can do the sum of a + b. -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 + //- added a + b to return so function returns the sum. // 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 5afd46042193c8b33f6b5f414a335aca936070d8 Mon Sep 17 00:00:00 2001 From: abmhts Date: Tue, 22 Sep 2026 21:37:14 +0100 Subject: [PATCH 07/17] BMI calculation code --- Sprint-3/2-mandatory-debug/2.js | 35 +++++++++++++++++++------ Sprint-3/3-mandatory-implement/1-bmi.js | 9 ++++++- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..444f66576 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -2,23 +2,42 @@ // Predict the output of the following code: // =============> Write your prediction here + //getting the last digit of 103 +// 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 + // -Every time the function calls 103 // =============> write your explanation here // Finally, correct the code to fix the problem // =============> write your new code here // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem + //The function was looking at the outside "num" but Now there are two (num) one outside the scope "const num= 103" and i added another inside the function scope. + //The function calculates something and returns it then console.log outside receives that returned value and prints. it. +const num = 103; + +function getLastDigit() { + return num.toString().slice(-1); + +// console.log(getLastDigit(42)); +} +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)}`); + + diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..6a48b723b 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -14,6 +14,13 @@ // Then when we call this function with the weight and height // 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 + const bmi= weight / (height * height); + return bmi.toFixed(1); + + // return the BMI of someone based off their weight and height } + + console.log(`Your BMI is ${calculateBMI(70, 1.73)}, based on your weight and height`); + From a379651291bbb9d9b965505fcbd2fab2409738a5 Mon Sep 17 00:00:00 2001 From: abmhts Date: Tue, 22 Sep 2026 21:49:44 +0100 Subject: [PATCH 08/17] fix of get last digit function error --- Sprint-3/2-mandatory-debug/2.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 444f66576..d85a928ba 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -2,8 +2,9 @@ // Predict the output of the following code: // =============> Write your prediction here - //getting the last digit of 103 -// const num = 103; + //-getting the last digit of 103 + + // const num = 103; // function getLastDigit() { // return num.toString().slice(-1); @@ -27,14 +28,14 @@ // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem - //The function was looking at the outside "num" but Now there are two (num) one outside the scope "const num= 103" and i added another inside the function scope. - //The function calculates something and returns it then console.log outside receives that returned value and prints. it. -const num = 103; + //-The function was looking at the outside "num" but Now there are two (num) one outside the scope "const num= 103" and i added another inside the function scope. + //-The function calculates something and returns it then console.log outside receives that returned value and prints it. + + const num = 103; -function getLastDigit() { +function getLastDigit(num) { return num.toString().slice(-1); -// console.log(getLastDigit(42)); } console.log(`The last digit of 42 is ${getLastDigit(42)}`); console.log(`The last digit of 105 is ${getLastDigit(105)}`); From e9fda6347ad29d634ad1242e2db5225bd8bef1c8 Mon Sep 17 00:00:00 2001 From: abmhts Date: Tue, 22 Sep 2026 22:24:50 +0100 Subject: [PATCH 09/17] convert to UPPER_SNAKE_CASE --- 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..8094fa8b6 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 convertToUpperCase(sentence) { + return sentence.toUpperCase().replaceAll(" ", "_"); + +} + console.log(convertToUpperCase("welcome to Chad")); From f0201ddff1f803121295b612ecbeeb8c322b1b4f Mon Sep 17 00:00:00 2001 From: abmhts Date: Wed, 23 Sep 2026 18:29:58 +0100 Subject: [PATCH 10/17] added function called toPounds --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 23 +++++++++++++++++++ 1 file changed, 23 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..e4d1fb331 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,26 @@ // 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("399p")); + console.log(toPounds("4000p")); + console.log(toPounds("39p")); + console.log(toPounds("3p")); \ No newline at end of file From c4470d9a6b5f18f47fc5df4a10e39c3f780eed42 Mon Sep 17 00:00:00 2001 From: abmhts Date: Wed, 23 Sep 2026 20:00:42 +0100 Subject: [PATCH 11/17] time-format --- Sprint-3/4-mandatory-interpret/time-format.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..d9fa62df7 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -14,7 +14,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } - +console.log(formatTimeDisplay()); // 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 +22,18 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here - + //- 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 + // b) What is the value assigned to num when pad is called for the first time? + //- 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, remainingSeconds is 1 because 61 % 60 = 1. The last call is pad(remainingSeconds) so pad(1) makes num = 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 + //- "01" , num.toString() changes 1 into "1". Since "1" has only 1 character, the while loop adds "0" in front, making "01". \ No newline at end of file From add8d2e320a44fa5975dd33b5e98922fbf63e6aa Mon Sep 17 00:00:00 2001 From: Abakar Date: Thu, 24 Sep 2026 11:33:31 +0100 Subject: [PATCH 12/17] Delete Sprint-2/3-mandatory-interpret/1-percentage-change.js --- .../1-percentage-change.js | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 Sprint-2/3-mandatory-interpret/1-percentage-change.js diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js deleted file mode 100644 index e2b19128e..000000000 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ /dev/null @@ -1,32 +0,0 @@ -let carPrice = "10,000"; -let priceAfterOneYear = "8,543"; - -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); - -const priceDifference = carPrice - priceAfterOneYear; -const percentageChange = (priceDifference / carPrice) * 100; - -console.log(`The percentage change is ${percentageChange}`); - -// Read the code and then answer the questions below - -// a) How many function calls are there in this file? Write down all the lines where a function call is made - 4 function calls - -Number(carPrice.replaceAll(",", "")) - -replaceAll(",", "") - -Number(priceAfterOneYear.replaceAll("," "")) - -replaceAll("," "") -// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? - -Line 5 - -missing ) after argument list - -why: replaceAll() needs two arguments separated by a comma. - -fix: by adding comma replaceAll(",", "") -// c) Identify all the lines that are variable reassignment statements - line 4 and 5 - -// d) Identify all the lines that are variable declarations - line 1,2,7 and 8 -// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? - -First removing the comma "10,000" - -Second convert string into number 10000 \ No newline at end of file From 73113c5a197b68c923b763359b7032be4590a2fb Mon Sep 17 00:00:00 2001 From: abmhts Date: Thu, 24 Sep 2026 12:40:12 +0100 Subject: [PATCH 13/17] Revert "Delete Sprint-2/3-mandatory-interpret/1-percentage-change.js" This reverts commit add8d2e320a44fa5975dd33b5e98922fbf63e6aa. --- .../1-percentage-change.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Sprint-2/3-mandatory-interpret/1-percentage-change.js diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js new file mode 100644 index 000000000..e2b19128e --- /dev/null +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -0,0 +1,32 @@ +let carPrice = "10,000"; +let priceAfterOneYear = "8,543"; + +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); + +const priceDifference = carPrice - priceAfterOneYear; +const percentageChange = (priceDifference / carPrice) * 100; + +console.log(`The percentage change is ${percentageChange}`); + +// Read the code and then answer the questions below + +// a) How many function calls are there in this file? Write down all the lines where a function call is made + 4 function calls + -Number(carPrice.replaceAll(",", "")) + -replaceAll(",", "") + -Number(priceAfterOneYear.replaceAll("," "")) + -replaceAll("," "") +// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? + -Line 5 + -missing ) after argument list + -why: replaceAll() needs two arguments separated by a comma. + -fix: by adding comma replaceAll(",", "") +// c) Identify all the lines that are variable reassignment statements + line 4 and 5 + +// d) Identify all the lines that are variable declarations + line 1,2,7 and 8 +// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + -First removing the comma "10,000" + -Second convert string into number 10000 \ No newline at end of file From fc9a86047cf3b74c3abe5af583c0ba3597b4b252 Mon Sep 17 00:00:00 2001 From: abmhts Date: Thu, 24 Sep 2026 12:54:23 +0100 Subject: [PATCH 14/17] Remove accidentally added file --- .../1-percentage-change.js | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 Sprint-2/3-mandatory-interpret/1-percentage-change.js diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js deleted file mode 100644 index e2b19128e..000000000 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ /dev/null @@ -1,32 +0,0 @@ -let carPrice = "10,000"; -let priceAfterOneYear = "8,543"; - -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); - -const priceDifference = carPrice - priceAfterOneYear; -const percentageChange = (priceDifference / carPrice) * 100; - -console.log(`The percentage change is ${percentageChange}`); - -// Read the code and then answer the questions below - -// a) How many function calls are there in this file? Write down all the lines where a function call is made - 4 function calls - -Number(carPrice.replaceAll(",", "")) - -replaceAll(",", "") - -Number(priceAfterOneYear.replaceAll("," "")) - -replaceAll("," "") -// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? - -Line 5 - -missing ) after argument list - -why: replaceAll() needs two arguments separated by a comma. - -fix: by adding comma replaceAll(",", "") -// c) Identify all the lines that are variable reassignment statements - line 4 and 5 - -// d) Identify all the lines that are variable declarations - line 1,2,7 and 8 -// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? - -First removing the comma "10,000" - -Second convert string into number 10000 \ No newline at end of file From 6501234f72d11fab792fca6b63538792bf5ebd5c Mon Sep 17 00:00:00 2001 From: abmhts Date: Thu, 24 Sep 2026 13:56:20 +0100 Subject: [PATCH 15/17] Restore Sprint-2 file --- .../1-percentage-change.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Sprint-2/3-mandatory-interpret/1-percentage-change.js diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js new file mode 100644 index 000000000..e24ecb8e1 --- /dev/null +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -0,0 +1,22 @@ +let carPrice = "10,000"; +let priceAfterOneYear = "8,543"; + +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); + +const priceDifference = carPrice - priceAfterOneYear; +const percentageChange = (priceDifference / carPrice) * 100; + +console.log(`The percentage change is ${percentageChange}`); + +// Read the code and then answer the questions below + +// a) How many function calls are there in this file? Write down all the lines where a function call is made + +// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? + +// c) Identify all the lines that are variable reassignment statements + +// d) Identify all the lines that are variable declarations + +// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? From 65e5b195ea8d621722167bd3be12dc21d69d2616 Mon Sep 17 00:00:00 2001 From: abmhts Date: Sat, 26 Sep 2026 15:19:14 +0100 Subject: [PATCH 16/17] Update- explaining the error, prediction, and fix --- Sprint-3/1-key-errors/1.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index ed809e14c..b4e5bee24 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -16,15 +16,18 @@ // console.log(decimalNumber); // =============> write your explanation here - //- "decimalNumber" is already provided as a parameter to the function, but I don't need a parameter because I'm creating the value "0.5" inside the function. So I removed the parameter. I also need to call the function with convertToPercentage() instead of console.log(decimalNumber) because "decimalNumber" only exists inside the function. -// Finally, correct the code to fix the problem + // I moved `const decimalNumber = 0.5` outside the function. The function already has `decimalNumber` as a parameter, so I can pass a number directly when calling it, like `convertToPercentage(7)`. The function then multiplies it by 100 and adds `%`. + // =============> write your new code here -function convertToPercentage() { - const decimalNumber = 0.5; +const decimalNumber = 0.5; + +function convertToPercentage(decimalNumber) { + const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(convertToPercentage()); +console.log(convertToPercentage(7)); + From 1b143ad7203bbca3bc69181329bdfe4b08f076d0 Mon Sep 17 00:00:00 2001 From: abmhts Date: Mon, 28 Sep 2026 11:59:51 +0100 Subject: [PATCH 17/17] update - explaining error msg and fix the code --- Sprint-3/1-key-errors/0.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 4220f10e5..f44062cad 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -14,6 +14,6 @@ //- I changed the variable name to "strg" to avoid the error. // =============> write your new code here function capitalise(str) { - let strg = `${str[0].toUpperCase()}${str.slice(1)}`; - return strg; -} \ No newline at end of file + return `${str[0].toUpperCase()}${str.slice(1)}`; +} +console.log(capitalise("abakar")); \ No newline at end of file