From 237a6b1577cb71987bf00085be2bcc25fdc6a593 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 20 Sep 2025 15:13:47 +0100 Subject: [PATCH 01/12] Correcting my answer --- Sprint-1/1-key-exercises/1-count.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..de40c5929 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,4 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing +//Line 3 taking the current value to count, then make the count to new value From 200e06c07ba98ce2f86129b3f98948c0ea4e882d Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 27 Sep 2025 14:44:21 +0100 Subject: [PATCH 02/12] Completed Sprint 1 coursework --- Sprint-1/1-key-exercises/1-count.js | 5 ++++- Sprint-1/1-key-exercises/2-initials.js | 3 ++- Sprint-1/1-key-exercises/3-paths.js | 8 +++++--- Sprint-1/1-key-exercises/4-random.js | 13 +++++++++++++ Sprint-1/2-mandatory-errors/0.js | 6 +++++- Sprint-1/2-mandatory-errors/1.js | 7 +++++++ Sprint-1/2-mandatory-errors/2.js | 9 +++++++++ Sprint-1/2-mandatory-errors/3.js | 9 +++++++++ Sprint-1/2-mandatory-errors/4.js | 10 +++++++++- .../3-mandatory-interpret/1-percentage-change.js | 15 +++++++++++++++ Sprint-1/3-mandatory-interpret/2-time-format.js | 7 +++++++ Sprint-1/3-mandatory-interpret/3-to-pounds.js | 9 +++++++++ Sprint-1/4-stretch-explore/chrome.md | 4 ++++ Sprint-1/4-stretch-explore/objects.md | 4 ++++ 14 files changed, 102 insertions(+), 7 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index de40c5929..3986d0991 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,4 +4,7 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing -//Line 3 taking the current value to count, then make the count to new value + +Answer: + +//Line 3 is assignment statement,its taking the current value to count,then make the count to a new value. \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..5ee11d5e5 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,8 @@ let lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -let initials = ``; +Answer: +let initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0); // https://www.google.com/search?q=get+first+character+of+string+mdn diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..255e6c3d1 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -16,8 +16,10 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable - -const dir = ; -const ext = ; +Anwer: +const dir = filePath.slice(0, lastSlashIndex); +const ext = base.slice(lastDotIndex + 1); +console.log(`The dir part of ${filePath} is ${dir}`); +console.log(`The ext part of ${filePath} is ${ext}`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..53f89bb75 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,16 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing + +Answer: + +//num is a random number between 1 and 100. + +//Math.random() makes a number between 0 and 1. + +//times (maximum - minimum + 1) makes it bigger. + +//Math.floor cuts off the decimal. + +//+ minimum makes sure the random number starts at 1 instead of 0 + diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..4d14d2c7d 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,6 @@ This is just an instruction for the first activity - but it is just for human consumption -We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file +We don't want the computer to run these 2 lines - how can we solve this problem? + +Answer: +//We can turn those lines into comments by putting // at the start. +//Then computer ignores them but humans can still read/see them. diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..d1cd24c47 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,3 +2,10 @@ const age = 33; age = age + 1; + +Answer: + +//This gives an error because we used const, which can't be changed. +// If we want to update the value, we should use let instead of const. +let age = 33; +age = age + 1; diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..9560bcd9e 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,12 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + + +Answer: + +//Error because cityOfBirth is used before it is declared. +//We need to define the variable first, then use it. + +const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..606c38bba 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -7,3 +7,12 @@ const last4Digits = cardNumber.slice(-4); // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? // Then try updating the expression last4Digits is assigned to, in order to get the correct value + +Answer: + +//I guessed it breaks because slice is for strings but cardNumber is a number. +//When I try it, the error says slice is not a function (so I was right). +//Fix: change the number to string first, then slice works. +const cardNumber = 4533787178994213; +const last4Digits = cardNumber.toString().slice(-4); +console.log(last4Digits); // 4213 diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..98dd10aba 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,10 @@ const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const 24hourClockTime = "08:53"; + + +Answer: + +// The first line is wrong cuz variable names can't start with a number. +// We should rename it like hour12ClockTime or something that doesn't start with a digit. +const hour12ClockTime = "20:53"; +const hour24ClockTime = "08:53"; diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..70d991a93 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,26 @@ 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 +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +console.log(`The percentage change is ${percentageChange}`); + // 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? +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +fix; +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // c) Identify all the lines that are variable reassignment statements +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); // d) Identify all the lines that are variable declarations +let carPrice = "10,000"; +let priceAfterOneYear = "8,543"; + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +replaceAll gets rid of the commas → "10,000" becomes "10000". +Number() turns that string into the number 10000. +so we can do maths with it. diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..ebf1a9c67 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,21 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? +6: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result. // b) How many function calls are there? +Only 1 ; console.log(result); // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +% gives the leftover after dividing, so movieLength % 60 = extra seconds // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +(movieLength - remainingSeconds)/60 → takes away seconds, then gets whole minutes + // e) What do you think the variable result represents? Can you think of a better name for this variable? +It’s the time of the movie written as hours:minutes:seconds. A better name could be movieTime or formattedTime. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +works for normal numbers, but long movies or single-digit mins/secs look weird \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..6243ddf9a 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,21 +1,30 @@ const penceString = "399p"; +sets the price string with "p" at the end + const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1 ); +//removes the p from the end + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2 ); +// makes sure it has at least 3 digits, adds 0 at start if needed + const pence = paddedPenceNumberString .substring(paddedPenceNumberString.length - 2) .padEnd(2, "0"); + // takes last 2 digits → pence, adds 0 at end if needed console.log(`£${pounds}.${pence}`); +// prints the price in pounds like £3.99 + // This program takes a string representing a price in pence // The program then builds up a string representing the price in pounds diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..ea58a5721 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -11,8 +11,12 @@ In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; What effect does calling the `alert` function have? +*It shows a popup message on the screen.* Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? +*pops up a box asking you to type something* + What is the return value of `prompt`? +*whatever the user typed (as a string)* diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..366db3207 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -7,10 +7,14 @@ Open the Chrome devtools Console, type in `console.log` and then hit enter What output do you get? Now enter just `console` in the Console, what output do you get back? +*shows a big list of all the stuff it can do, like log, assert, and other functions* Try also entering `typeof console` Answer the following questions: What does `console` store? +*console stores all the console functions you can use.* + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +*the . means “use a function from console.* From d50491caba472093a100000f2f53f3371ecfa559 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 00:09:16 +0100 Subject: [PATCH 03/12] finished my tasks --- Sprint-2/1-key-errors/0.js | 18 ++++++++++++++++++ Sprint-2/1-key-errors/1.js | 25 ++++++++++++++++++++++++- Sprint-2/1-key-errors/2.js | 19 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..7c8044818 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -9,5 +9,23 @@ function capitalise(str) { return str; } + // =============> write your explanation here // =============> write your new code here + +///The error is : + +let str = `${str[0].toUpperCase()}${str.slice(1)}`; + +//str is already a parameter of the function. +//Doing let str = ... is like giving it a new name in the same place, which JavaScript does not allow. +//we can just use the existing str instead of declaring it again. + +function capitalise(str) { + + // make the first letter uppercase + + str = str[0].toUpperCase() + str.slice(1); + + return str; +} diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..62a0e70d3 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -9,12 +9,35 @@ function convertToPercentage(decimalNumber) { const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; - return percentage; + return percentage;= } console.log(decimalNumber); // =============> write your explanation here +Answer: + +The number (0.5) goes into the function — that’s our decimalNumber. + +We use that decimalNumber to make a percent. + +We don’t write const decimalNumber again because we already have it. + +We return the answer (like "50%"). + +Then we call the function with 0.5 and print what it gives back. + // 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)); + diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..c90def798 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -6,15 +6,34 @@ // =============> write your prediction of the error here function square(3) { + return num * num; } // =============> write the error message here +SyntaxError: Unexpected number + + // =============> explain this error message here +the function takes the number we give it (3) and times it by itself. + +so 3 * 3 = 9. + +it works now cuz we used num instead of a number in the () + + // Finally, correct the code to fix the problem // =============> write your new code here +function square(num){ + + return num * num + } + + console.log(square(3)) + + From 6f122b74cc00e95a8b04d11ecf7c59ce7cdf2171 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 07:36:01 +0100 Subject: [PATCH 04/12] Finished my tasks --- Sprint-2/1-key-errors/0.js | 1 - Sprint-2/1-key-errors/1.js | 1 - Sprint-2/1-key-errors/2.js | 1 - Sprint-2/2-mandatory-debug/0.js | 12 ++++++++++++ Sprint-2/2-mandatory-debug/1.js | 13 +++++++++++++ Sprint-2/2-mandatory-debug/2.js | 34 +++++++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 7c8044818..8f466e809 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -9,7 +9,6 @@ function capitalise(str) { return str; } - // =============> write your explanation here // =============> write your new code here diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 62a0e70d3..8cad2edf7 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -11,7 +11,6 @@ function convertToPercentage(decimalNumber) { return percentage;= } - console.log(decimalNumber); // =============> write your explanation here diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index c90def798..e14f62d24 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -9,7 +9,6 @@ function square(3) { return num * num; } - // =============> write the error message here SyntaxError: Unexpected number diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..eadee6a4e 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -10,5 +10,17 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here +the function just prints the answer, it dont return it. + +so when we try to use it inside the message it shows 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)}`) + diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..5a14317ae 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -9,5 +9,18 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here + +the code dont work cuz the return stops the code before it adds the numbers. + +so js never does a + b, that’s why it show 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)}`) + diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..376171437 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,11 +1,19 @@ // Predict and explain first... +it will print 3 for all of them + // Predict the output of the following code: + +The last digit of 42 is 3 +The last digit of 105 is 3 +The last digit of 806 is 3 + // =============> Write your prediction here const num = 103; function getLastDigit() { + return num.toString().slice(-1); } @@ -15,9 +23,35 @@ 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 2 + +The last digit of 105 is 5 + +The last digit of 806 is 6 + // Explain why the output is the way it is // =============> write your explanation here + +It always shows 3 cuz the function just uses the num at the top (103). + +It ignores the numbers we put in () like 42, 105, 806. + +We need to let the function take a number as input. + // Finally, correct the code to fix the problem + +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)}) + // =============> write your new code here // This program should tell the user the last digit of each number. From 192c85e121f1875f5225e4f4c7d18bc7af189abc Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 08:37:08 +0100 Subject: [PATCH 05/12] Added missing const variable declaration --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 70d991a93..4574662d8 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -27,11 +27,16 @@ carPrice = Number(carPrice.replaceAll(",", "")); priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); // d) Identify all the lines that are variable declarations + let carPrice = "10,000"; let priceAfterOneYear = "8,543"; +const priceDifference = carPrice - priceAfterOneYear; +const percentageChange = (priceDifference / carPrice) * 100; // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? replaceAll gets rid of the commas → "10,000" becomes "10000". + Number() turns that string into the number 10000. + so we can do maths with it. From 67ff52fbaa292474013a1fe8450d000a6b017bfe Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 10:10:49 +0100 Subject: [PATCH 06/12] Added missing const variable declaration --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 4574662d8..84caa4b02 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -30,10 +30,10 @@ priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); let carPrice = "10,000"; let priceAfterOneYear = "8,543"; + const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; - // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? replaceAll gets rid of the commas → "10,000" becomes "10000". From a3f32c3c6baf57e5660cfd12ce02580f37097d32 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 10:12:14 +0100 Subject: [PATCH 07/12] Added missing const variable declarations --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 84caa4b02..3e298990c 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -30,7 +30,6 @@ priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); let carPrice = "10,000"; let priceAfterOneYear = "8,543"; - const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; From 80ad492b3a5df2b29fc96466888cd9c9468113ae Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 10:12:56 +0100 Subject: [PATCH 08/12] added missing const --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 3e298990c..84caa4b02 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -30,6 +30,7 @@ priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); let carPrice = "10,000"; let priceAfterOneYear = "8,543"; + const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; From 6fa3bb909447fb488ca9b6994b1fb488e2e99828 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 12:06:46 +0100 Subject: [PATCH 09/12] Finished my tasks --- Sprint-2/3-mandatory-implement/1-bmi.js | 16 ++++++++++-- Sprint-2/3-mandatory-implement/2-cases.js | 15 +++++++++++ Sprint-2/3-mandatory-implement/3-to-pounds.js | 25 +++++++++++++++++++ 3 files changed, 54 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..20328da1a 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -14,6 +14,18 @@ // Then when we call this function with the weight and height // It should return their Body Mass Index to 1 decimal place -function calculateBMI(weight, height) { +function calculateBmi(weight,height) { // return the BMI of someone based off their weight and height -} \ No newline at end of file +} + + +function calculateBMI (weight,height) { + + let bmi = weight / (height*height) + + return bmi.toFixed(1) + + } + + console.log(calculateBMI(70,1.73)) + \ No newline at end of file diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..767f25910 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,18 @@ // 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 that turns text into UPPER_SNAKE_CASE + +function makeUpperSnake(text) { + + let newText =text.replace(/ /g,'_'); + + newText = newText.toUpperCase(); + + return newText; + + } + console.log(makeUpperSnake("hello there")); + console.log(makeUpperSnake("lord of the rings")); + + diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..49a148267 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/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) { + + let numberStr =penceString.substring(0,penceString.length -1); + + numberStr = numberStr.padStart(3,"0"); + + let pounds = numberStr.substring(0, numberStr.length -2); + + let pence = numberStr.substring(numberStr.length -2).padEnd(2,"0"); + + return "£" +pounds + "." +pence; + } + +console.log(toPounds("399p")); +console.log(toPounds("50p")); +console.log(toPounds("5p")); +console.log(toPounds("1200p")); + + + + From 59316af444c163552f4d5db8df7e2be4eab358f3 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 12:28:03 +0100 Subject: [PATCH 10/12] Revert "Finished my tasks" This reverts commit 6fa3bb909447fb488ca9b6994b1fb488e2e99828. --- Sprint-2/3-mandatory-implement/1-bmi.js | 16 ++---------- Sprint-2/3-mandatory-implement/2-cases.js | 15 ----------- Sprint-2/3-mandatory-implement/3-to-pounds.js | 25 ------------------- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 20328da1a..17b1cbde1 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -14,18 +14,6 @@ // Then when we call this function with the weight and height // It should return their Body Mass Index to 1 decimal place -function calculateBmi(weight,height) { +function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height -} - - -function calculateBMI (weight,height) { - - let bmi = weight / (height*height) - - return bmi.toFixed(1) - - } - - console.log(calculateBMI(70,1.73)) - \ No newline at end of file +} \ No newline at end of file diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 767f25910..5b0ef77ad 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,18 +14,3 @@ // 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 that turns text into UPPER_SNAKE_CASE - -function makeUpperSnake(text) { - - let newText =text.replace(/ /g,'_'); - - newText = newText.toUpperCase(); - - return newText; - - } - console.log(makeUpperSnake("hello there")); - console.log(makeUpperSnake("lord of the rings")); - - diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 49a148267..6265a1a70 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,28 +4,3 @@ // 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) { - - let numberStr =penceString.substring(0,penceString.length -1); - - numberStr = numberStr.padStart(3,"0"); - - let pounds = numberStr.substring(0, numberStr.length -2); - - let pence = numberStr.substring(numberStr.length -2).padEnd(2,"0"); - - return "£" +pounds + "." +pence; - } - -console.log(toPounds("399p")); -console.log(toPounds("50p")); -console.log(toPounds("5p")); -console.log(toPounds("1200p")); - - - - From df8c275ba8ac2a4dcdadf47ddb22cf1ddf0363ed Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 12:52:16 +0100 Subject: [PATCH 11/12] Undo changes in sprint2 This reverts commit 6f122b74cc00e95a8b04d11ecf7c59ce7cdf2171. --- Sprint-2/1-key-errors/0.js | 1 + Sprint-2/1-key-errors/1.js | 1 + Sprint-2/1-key-errors/2.js | 1 + Sprint-2/2-mandatory-debug/0.js | 12 ------------ Sprint-2/2-mandatory-debug/1.js | 13 ------------- Sprint-2/2-mandatory-debug/2.js | 34 --------------------------------- 6 files changed, 3 insertions(+), 59 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 8f466e809..7c8044818 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -9,6 +9,7 @@ function capitalise(str) { return str; } + // =============> write your explanation here // =============> write your new code here diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 8cad2edf7..62a0e70d3 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -11,6 +11,7 @@ function convertToPercentage(decimalNumber) { return percentage;= } + console.log(decimalNumber); // =============> write your explanation here diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index e14f62d24..c90def798 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -9,6 +9,7 @@ function square(3) { return num * num; } + // =============> write the error message here SyntaxError: Unexpected number diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index eadee6a4e..b27511b41 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -10,17 +10,5 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here -the function just prints the answer, it dont return it. - -so when we try to use it inside the message it shows 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)}`) - diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 5a14317ae..37cedfbcf 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -9,18 +9,5 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here - -the code dont work cuz the return stops the code before it adds the numbers. - -so js never does a + b, that’s why it show 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)}`) - diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 376171437..57d3f5dc3 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,19 +1,11 @@ // Predict and explain first... -it will print 3 for all of them - // Predict the output of the following code: - -The last digit of 42 is 3 -The last digit of 105 is 3 -The last digit of 806 is 3 - // =============> Write your prediction here const num = 103; function getLastDigit() { - return num.toString().slice(-1); } @@ -23,35 +15,9 @@ 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 2 - -The last digit of 105 is 5 - -The last digit of 806 is 6 - // Explain why the output is the way it is // =============> write your explanation here - -It always shows 3 cuz the function just uses the num at the top (103). - -It ignores the numbers we put in () like 42, 105, 806. - -We need to let the function take a number as input. - // Finally, correct the code to fix the problem - -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)}) - // =============> write your new code here // This program should tell the user the last digit of each number. From 4d0c91de7586a4c72e81790cb1bcf28a41de67a5 Mon Sep 17 00:00:00 2001 From: Shayida Date: Sat, 18 Oct 2025 12:53:51 +0100 Subject: [PATCH 12/12] Revert "finished my tasks" This reverts commit d50491caba472093a100000f2f53f3371ecfa559. --- Sprint-2/1-key-errors/0.js | 18 ------------------ Sprint-2/1-key-errors/1.js | 25 +------------------------ Sprint-2/1-key-errors/2.js | 19 ------------------- 3 files changed, 1 insertion(+), 61 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 7c8044818..653d6f5a0 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -9,23 +9,5 @@ function capitalise(str) { return str; } - // =============> write your explanation here // =============> write your new code here - -///The error is : - -let str = `${str[0].toUpperCase()}${str.slice(1)}`; - -//str is already a parameter of the function. -//Doing let str = ... is like giving it a new name in the same place, which JavaScript does not allow. -//we can just use the existing str instead of declaring it again. - -function capitalise(str) { - - // make the first letter uppercase - - str = str[0].toUpperCase() + str.slice(1); - - return str; -} diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index 62a0e70d3..f2d56151f 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -9,35 +9,12 @@ function convertToPercentage(decimalNumber) { const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; - return percentage;= + return percentage; } console.log(decimalNumber); // =============> write your explanation here -Answer: - -The number (0.5) goes into the function — that’s our decimalNumber. - -We use that decimalNumber to make a percent. - -We don’t write const decimalNumber again because we already have it. - -We return the answer (like "50%"). - -Then we call the function with 0.5 and print what it gives back. - // 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)); - diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index c90def798..aad57f7cf 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -6,34 +6,15 @@ // =============> write your prediction of the error here function square(3) { - return num * num; } // =============> write the error message here -SyntaxError: Unexpected number - - // =============> explain this error message here -the function takes the number we give it (3) and times it by itself. - -so 3 * 3 = 9. - -it works now cuz we used num instead of a number in the () - - // Finally, correct the code to fix the problem // =============> write your new code here -function square(num){ - - return num * num - } - - console.log(square(3)) - -