From 644e205065d9db8851c0cea33e3f3637aa7618ef Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 00:02:02 +0000 Subject: [PATCH 01/13] Exercise 1 - Incrementing --- Sprint-1/1-key-exercises/1-count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..07994c22f 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,5 @@ 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 +// = It assign the value of the variable count added to 1, it's called Incrementing +// Also Line 3, could be written as such count++; according to doc From bd37553dcf466891d74a2d02ac9f345d24ed04e5 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 00:38:34 +0000 Subject: [PATCH 02/13] Implement initials extraction from first, middle, and last names --- Sprint-1/1-key-exercises/2-initials.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..1040668fe 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,12 @@ 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); +// I understood that charAt(0) gets the first character of the string. also I can concatenate strings with the + operator +// I can also use bracket notation/ Index access to get the first character of the string like this: firstName[0] + middleName[0] + lastName[0] + +console.log(initials); + // https://www.google.com/search?q=get+first+character+of+string+mdn From 3fca4c998a8a0972c4f5183a0612888f2313a907 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 01:01:47 +0000 Subject: [PATCH 03/13] Implement dir and ext extraction from filePath --- 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 ab90ebb28..8ab3ce308 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(".")); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 02c8df6edcf8d2e59b2755dfc55729fc6ed1c803 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 01:15:19 +0000 Subject: [PATCH 04/13] Enhance random number generation explanation and documentation --- 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 292f83aab..223ec2e91 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,14 @@ 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 + +console.log(num); + +// I understand that Math.random() generates a random number between 0 and 1, +// and multiplies it by the range (maximum - minimum + 1) to get a number in that range. +// and then adds the minimum to shift the range to start from the minimum value 1 -> 100 rather than 0 -> 99. +// finally, Math.floor() rounds the number down. + +// docs for Math.random() and Math.floor() I used: +// https://www.google.com/search?q=Math.random+mdn +// https://www.google.com/search?q=Math.floor+mdn From 8b1f048fc6f08508592376b38cd880fbf254d857 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 01:21:42 +0000 Subject: [PATCH 05/13] Refactor comments in mandatory error examples for clarity and instruction --- Sprint-1/2-mandatory-errors/0.js | 5 +++-- Sprint-1/2-mandatory-errors/1.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..ab0143c25 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,3 @@ -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? +// by simply commenting out the lines with // the computer will ignore these lines and not run them \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..02a338fec 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,13 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +// const age = 33; +// age = age + 1; + +// this code will throw an error because age is declared as a constant and we cannot reassign a new value to a constant variable + +// To fix this error, we can change the declaration of age from const to let + +let age = 33; age = age + 1; + +// Now the code will work without throwing an error, and the value of age will be updated to 34. From e1e04e82def469bf2492e36a154dc975dd3cd723 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 01:23:27 +0000 Subject: [PATCH 06/13] Add clarification comment on variable hoisting error in example --- Sprint-1/2-mandatory-errors/2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..19599282d 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,5 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +// The error is that we are trying to use the variable cityOfBirth before it has been declared and assigned a value. From 4247c11fb4b7f7990c16400e7f5edcb2cba873e2 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 01:27:01 +0000 Subject: [PATCH 07/13] Fix last4Digits extraction by clarifying type error in comments --- Sprint-1/2-mandatory-errors/3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..5e29de3a6 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -7,3 +7,7 @@ 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 + +console.log(last4Digits); + +// The error is that cardNumber is a number and the slice method is a string method, so we cannot use slice on a number. \ No newline at end of file From e781b958466983c2a687fbb42e63167da844bb66 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Tue, 24 Feb 2026 01:32:14 +0000 Subject: [PATCH 08/13] Clarify variable naming rules in comments and enhance example output for better understanding --- Sprint-1/2-mandatory-errors/4.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..e79bdda2c 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,12 @@ const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const 24hourClockTime = "08:53"; + + + +console.log(12HourClockTime); +console.log(24hourClockTime); + +// it throws a SyntaxError: Invalid or unexpected token because variable names cannot start with a number. +// The error is that we are trying to assign a string value to a variable that starts with a number, which is not allowed in JavaScript. +// Variable names cannot start with a number. + From 7459cb4a4aa69b73db11d63e1f164f8e2d01f890 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Fri, 27 Feb 2026 02:48:48 +0000 Subject: [PATCH 09/13] fix: Calculate percentage change between initial and final car prices --- .../1-percentage-change.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..20b7d9735 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,30 @@ 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 5 function calls in this file. The lines where a function call is made are: +// Line 1: carPrice.replaceAll(",", "") +// Line 2: priceAfterOneYear.replaceAll(",", "") +// Line 3: Number(carPrice.replaceAll(",", "")) +// Line 4: Number(priceAfterOneYear.replaceAll(",", "")) +// Line 5: 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? +// The error is occurring in line 5, because it's missing a comma between the two arguments of the replaceAll method. +// to fix this problem, we can add a comma between the two arguments: priceAfterOneYear.replaceAll(",", "") // c) Identify all the lines that are variable reassignment statements +// there are 2 variable reassignment statements in this file. The lines where a variable reassignment is made are: +// Line 4 and 5 where we are reassigning new values to the variables +// carPrice and priceAfterOneYear after converting them to numbers and removing the commas. // d) Identify all the lines that are variable declarations +// there are 4 variable declarations in this file. The lines where a variable declaration is made are: +// Line 1: let carPrice = "10,000"; +// Line 2: let priceAfterOneYear = "8,543"; +// Line 6: const priceDifference = carPrice - priceAfterOneYear; +// Line 7: const percentageChange = (priceDifference / carPrice) * 100; // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// To remove the commas from the string carPrice and convert the resulting string to a number. +// Then, the Number function is used to convert the resulting string into a number data type, +// which can be used for mathematical operations. \ No newline at end of file From 9fbb996c46c51ea56644cc8f26c682eb6652b095 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Fri, 27 Feb 2026 03:03:57 +0000 Subject: [PATCH 10/13] supported variable types and edge cases for movie timer --- Sprint-1/3-mandatory-interpret/2-time-format.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..560082bf1 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,25 @@ 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. // b) How many function calls are there? +// There is 1 function call, which is 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 +// % is Remainder operator. In this case, movieLength % 60 gives us the number of seconds +// that are left after we have taken out all the full minutes from the movie length. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// calculates the total number of minutes in the movie length, +// excluding the remaining seconds that are less than a full minute. // 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 in hours, minutes, and seconds. +// A better name for this variable could be movieFormattedTime. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// This code will work for all non-negative integer values of movieLength. +// However, if movieLength is a negative number, the result will be weird format with negative numbers. +// Moreover, if movieLength is not an integer, the result will also be weird format with decimal numbers. \ No newline at end of file From 25d601fe5789be0495cac39b87f2dc9333a87bc8 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Fri, 27 Feb 2026 03:16:20 +0000 Subject: [PATCH 11/13] Enhance comments with detailed step-by-step breakdown of price conversion logic --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..9a3fdbf12 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,8 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): removes the "p" from the string to get "399" +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): ensure it has at least 3 characters, resulting in "399" +// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds part by taking the substring from the start to the length minus 2, resulting in "3" +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence part by taking the last two characters and pads it with trailing zeros if necessary, resulting in "99" +// 6. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence, which is "£3.99" From 3da742fe9f5ab65bfcaecf8effd175923bd00009 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Fri, 27 Feb 2026 13:40:47 +0000 Subject: [PATCH 12/13] Enhance comments --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 9a3fdbf12..376b7e29e 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -26,7 +26,11 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" // 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): removes the "p" from the string to get "399" -// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): ensure it has at least 3 characters, resulting in "399" -// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds part by taking the substring from the start to the length minus 2, resulting in "3" -// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence part by taking the last two characters and pads it with trailing zeros if necessary, resulting in "99" -// 6. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence, which is "£3.99" +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): ensure it has at least 3 characters, resulting in "399" , +// for example if the input was "99p", it would become "099" after padding, ensuring we can correctly extract pounds and pence in the next steps. +// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): +// extracts the pounds part by taking the substring from the start to the length minus 2, resulting in "3" +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): +// extracts the pence part by taking the last two characters and pads it with trailing zeros if necessary, resulting in "99" +// 6. console.log(`£${pounds}.${pence}`): +// outputs the final formatted price in pounds and pence, which is "£3.99" From 25768ef6eddccfa2271229e019123d29199d9d34 Mon Sep 17 00:00:00 2001 From: Darkidd77 Date: Fri, 27 Feb 2026 14:35:30 +0000 Subject: [PATCH 13/13] Enhance explanations and examples --- Sprint-1/4-stretch-explore/chrome.md | 5 +++++ Sprint-1/4-stretch-explore/objects.md | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..3c5d43e0c 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -11,8 +11,13 @@ In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; What effect does calling the `alert` function have? +An alert message displays in chrome, the content of the message is the webpage or the website says the string i typed in an alert way. 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 allows you to input a value in box the browser displays, in this example myName was assigned using = with a value i inputted after running the code. + What is the return value of `prompt`? +The string you input in the field. but after looking more into it, +there is an edge case where the user can click cancel in this situation the return value is null which means absences of value. diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..f7d7ee6d8 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,27 @@ 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? +console.log +ƒ log() { [native code] } +ƒ stands for "function" +[native code] part just means it's a function built in so we can't see the actual underlying JavaScript code for it. Now enter just `console` in the Console, what output do you get back? +console +console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} +I think it gives a options of methods i can use with the object console. Try also entering `typeof console` +typeof console +'object' +from the name i can understand that typeof tells you the variable type so for console its object type. Answer the following questions: What does `console` store? +It stores a collection of methods. + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? + It means that i want to use a method (e.g. `log` or `assert`) that belong to an object (e.g. `console`) + `.` is dot notation, it means get the method from the object. +