From 8095f51f5795ebf98019f91b6813944b6a99228c Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 14:43:36 +0100 Subject: [PATCH 01/15] Refactor initials variable assignment to directly concatenate first characters --- Sprint-1/1-key-exercises/1-count.js | 5 +++++ Sprint-1/1-key-exercises/2-initials.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..8762a3ecea 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,8 @@ 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 is updating the value of the variable "count". +The "=" operator is an assignment operator, which means it takes "count + 1") +and assigns it to the variable on the left side "count". +So, it takes the current value of "count", adds 1 to it, +and then stores that new value back into "count". diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..202c67880c 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,7 @@ 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 = ``; +let initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0); // https://www.google.com/search?q=get+first+character+of+string+mdn From 3fd21e68bc45c7f8b7bec874db082449fe827767 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 15:05:41 +0100 Subject: [PATCH 02/15] Implement dir and ext variable assignments in file path extraction --- Sprint-1/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..fbe113e0f8 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,7 @@ 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 = ; +const dir = filePath.slice(0, lastSlashIndex); +const ext = filePath.slice(filePath.lastIndexOf(".") + 1); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 688f25b6ca5968f893ecd198fddfb0996aca9998 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 15:30:04 +0100 Subject: [PATCH 03/15] Breaking the expression and explaining what they mean --- Sprint-1/1-key-exercises/4-random.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..361e13fd35 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -4,6 +4,17 @@ const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // In this exercise, you will need to work out what num represents? + // Try breaking down the expression and using documentation to explain what it means + +The expression Math.floor() rounds a number down to the nearest integer. +The expression Math.random() generates a random floating-point number between 0 and 1. +The expression (maximum - minimum + 1) calculates the range of numbers between the minimum and maximum values. +The expression Math.random() * (maximum - minimum + 1) generates a random floating-point number between 0 and the range of numbers. +The expression Math.floor(Math.random() * (maximum - minimum + 1)) rounds that random number down to the nearest integer, resulting in a random integer between 0 and the range of numbers. +Finally, adding minimum to that result shifts the range to be between the minimum and maximum values. // 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 + +console.log(num); + From 63c562acc30e3f3fff22977aec9837711ac454f3 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 15:54:31 +0100 Subject: [PATCH 04/15] Improve documentation clarity by adding inline comments to expressions in random number generation --- Sprint-1/1-key-exercises/4-random.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 361e13fd35..8c75dcccd6 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,12 +7,12 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Try breaking down the expression and using documentation to explain what it means -The expression Math.floor() rounds a number down to the nearest integer. -The expression Math.random() generates a random floating-point number between 0 and 1. -The expression (maximum - minimum + 1) calculates the range of numbers between the minimum and maximum values. -The expression Math.random() * (maximum - minimum + 1) generates a random floating-point number between 0 and the range of numbers. -The expression Math.floor(Math.random() * (maximum - minimum + 1)) rounds that random number down to the nearest integer, resulting in a random integer between 0 and the range of numbers. -Finally, adding minimum to that result shifts the range to be between the minimum and maximum values. +The expression Math.floor() //rounds a number down to the nearest integer. +The expression Math.random() //generates a random floating-point number between 0 and 1. +The expression (maximum - minimum + 1) //calculates the range of numbers between the minimum and maximum values. +The expression Math.random() * (maximum - minimum + 1) //generates a random floating-point number between 0 and the range of numbers. +The expression Math.floor(Math.random() * (maximum - minimum + 1)) //rounds that random number down to the nearest integer, resulting in a random integer between 0 and the range of numbers. +Finally, adding minimum to that result //shifts the range to be between the minimum and maximum values. // 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 From cab937ea182df9184bbbf227fae4aa45a77144b8 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 15:58:31 +0100 Subject: [PATCH 05/15] Add comments to prevent execution of instructional lines in 0.js --- Sprint-1/2-mandatory-errors/0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..65ad3030d6 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,2 @@ -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 +//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 From 7186dfa36580b5ff5bf89e1309023755b3a7e7ce Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 16:04:26 +0100 Subject: [PATCH 06/15] Change age variable declaration from const to let for reassignment --- Sprint-1/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea76..8c5e17a24d 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; age = age + 1; +console.log(age); \ No newline at end of file From 27bff530764fec8ede4b6f6d9864e5d54750f838 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 16:06:53 +0100 Subject: [PATCH 07/15] Fix console log placement to correctly print city of birth --- Sprint-1/2-mandatory-errors/2.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831d..d117a49e65 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,8 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? -console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); + + + From 2f2a720920cf517ae97811cb88a4a8efa98c8b75 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 16:19:46 +0100 Subject: [PATCH 08/15] Fix last4Digits assignment to correctly use slice on string representation of cardNumber --- Sprint-1/2-mandatory-errors/3.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884db..2965b98f81 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,9 +1,21 @@ const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +const last4Digits = cardNumber.toString().slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working // Before running the code, make and explain a prediction about why the code won't work + +The code didnt work because the slice method was called on an integer (cardNumber), +but slice is a method that is only available for strings and arrays. +Since cardNumber is an integer, it does not have the slice method, +which will result in an error when the code is run. + // Then run the code and see what error it gives. +The error was: TypeError: cardNumber.slice is not a function + // Consider: Why does it give this error? Is this what I predicted? If not, what's different? +It gives this error because the slice method is not meant for numbers. This is what I predicted, as I expected that calling slice on an integer would result in a TypeError. + // Then try updating the expression last4Digits is assigned to, in order to get the correct value + +const last4Digits = cardNumber.toString().slice(-4); From 1cc8d569ddaf17cb8fca1574be3571fb1f17405c Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 16:29:46 +0100 Subject: [PATCH 09/15] Fix variable naming to follow camelCase convention for clock time constants --- Sprint-1/2-mandatory-errors/4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 5f86c730bc..b0feba1bbc 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,2 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const twelveHourClockTime = "8:53pm"; +const twentyFourHourClockTime = "20:53"; From 89ca1edf7a0e6bb63c77339aea5ed0f7e097bb4e Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 18:38:56 +0100 Subject: [PATCH 10/15] Add detailed comments to explain function calls, error identification, variable reassignment, and expression purpose in 1-percentage-change.js --- .../1-percentage-change.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e18..2abe94b1f0 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,35 @@ 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 +there are 4 function calls in this file. +The lines where a function call is made are: + +1. carPrice.replaceAll(",", "") +2. Number(carPrice.replaceAll(",", "")) +3. priceAfterOneYear.replaceAll("," "") +4. Number(priceAfterOneYear.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? +the error is coming from the line: +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); + +The error is occurring because there is a missing comma in the replaceAll method. The correct syntax should be: + +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // c) Identify all the lines that are variable reassignment statements +The lines that are variable reassignment statements are: +1. carPrice = Number(carPrice.replaceAll(",", "")); +2. priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // d) Identify all the lines that are variable declarations +The lines that are variable declarations are: +1. let carPrice = "10,000"; +2. let priceAfterOneYear = "8,543"; +3. const priceDifference = carPrice - priceAfterOneYear; +4. const percentageChange = (priceDifference / carPrice) * 100; // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +The expression Number(carPrice.replaceAll(",", "")) is performing two operations: +1. It is using the replaceAll method to remove all commas from the string value of carPrice, resulting in a string that represents a number without any formatting (e.g., "10000"). +2. It is then converting that string into a number using the Number() function, so that it can be used in mathematical calculations. From f402c6fd00d5eddbb029a4f76225f64b215b9d45 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 19:06:06 +0100 Subject: [PATCH 11/15] Enhance comments for clarity on variable declarations, function calls, and expressions in 2-time-format.js --- Sprint-1/3-mandatory-interpret/2-time-format.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d2395587..5b97e24cbc 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,26 @@ 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? +There are 6 variable declarations in this program. The variables declared are: +1. movieLength // b) How many function calls are there? +There is 1 function call in this program. The function called is: +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 +// The expression movieLength % 60 represents the remainder when movieLength is divided by 60. This gives us the number of seconds that are left over after converting the total seconds into minutes. + // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// The expression assigned to totalMinutes represents the total number of minutes in the movie, excluding the remaining seconds. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// The variable result represents the formatted time string in the format "hours:minutes:seconds". +// A better name for this variable could be formattedTime. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +//The code will work for all non-negative integer values of movieLength. +//It assumes that the input will always be a valid number of seconds. +//If the input is negative or not a number, the results will be unexpected. \ No newline at end of file From ed8a5e7f06896fe827edf3e286e111b696cfde20 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 20:35:50 +0100 Subject: [PATCH 12/15] Add detailed comments to explain each step of the pence to pounds conversion process in 3-to-pounds.js --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69a..5f4ac06b39 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,31 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 +); +// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): +// creates a new string variable that removes the last character "p" from the original string + +const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): +// pads the string with leading zeros to ensure it has at least 3 characters + +const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 +); +// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): +// extracts the substring representing the pounds by taking all characters except the last two + +const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): +// extracts the last two characters representing the pence and pads it with trailing zeros if necessary + +console.log(`£${pounds}.${pence}`); +// 6. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence to the console + + From 9d06c8b5106c8314c7ad16a8a079a3908d35259b Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 20:44:13 +0100 Subject: [PATCH 13/15] Refactor comments for clarity and consistency in 3-to-pounds.js --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 5f4ac06b39..5bb050ed25 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,31 +25,22 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" -const penceStringWithoutTrailingP = penceString.substring( - 0, - penceString.length - 1 -); + // 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): // creates a new string variable that removes the last character "p" from the original string -const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): // pads the string with leading zeros to ensure it has at least 3 characters -const pounds = paddedPenceNumberString.substring( - 0, - paddedPenceNumberString.length - 2 -); + // 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): // extracts the substring representing the pounds by taking all characters except the last two -const pence = paddedPenceNumberString - .substring(paddedPenceNumberString.length - 2) - .padEnd(2, "0"); + // 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): // extracts the last two characters representing the pence and pads it with trailing zeros if necessary -console.log(`£${pounds}.${pence}`); + // 6. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence to the console From d3193ff32b9308885edcadee2366c7e2eabbc1bf Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 21:18:24 +0100 Subject: [PATCH 14/15] Add explanations for prompt function effects in chrome.md --- Sprint-1/4-stretch-explore/chrome.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feafe..60607b0e13 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -15,4 +15,7 @@ What effect does calling the `alert` function have? 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? +It pops up an imput requesting my name + What is the return value of `prompt`? +The text i typed in the prompt From d60c97290c4bcebe44945a93b8949485f8e2f0f0 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 13 Jun 2026 21:28:50 +0100 Subject: [PATCH 15/15] Enhance explanations in objects.md for console output and syntax usage --- Sprint-1/4-stretch-explore/objects.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56a..d94a9c1699 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,20 @@ In this activity, we'll explore some additional concepts that you'll encounter i Open the Chrome devtools Console, type in `console.log` and then hit enter What output do you get? +ƒ log() { [native code] } Now enter just `console` in the Console, what output do you get back? +console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} Try also entering `typeof console` +'object' Answer the following questions: What does `console` store? +It stores a collection of functions and properties related to debugging and logging. + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? + +The syntax represents accesing a function stored inside an object. +The dot "." is an operator in JavaScript used to look inside an object to access its intertnal properties.