From d778f5cb3854d7b7134fa77b0d96057e6a3497b0 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Mon, 21 Sep 2026 17:58:00 +0100 Subject: [PATCH 01/13] Added comment about line 3 --- Sprint-2/1-key-exercises/1-count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..8effca019 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/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 + +// Line 3 is updating the value of the variable `count`. The `=` operator is an assignment operator, which means it takes the value on the right side (in this case, `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`. \ No newline at end of file From b04b2428ee8a99ec5a2c084d31fdf94448d95e01 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Tue, 22 Sep 2026 16:49:00 +0100 Subject: [PATCH 02/13] Add initials solution --- Sprint-2/1-key-exercises/2-initials.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 964c9563c..a04b4d886 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,6 +5,7 @@ const 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. -const initials = ``; +const initials =firstName[0] + middleName[0] + lastName[0]; +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From 8a27562a65a04a0ea080bb1ae133c46e74acde11 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Tue, 22 Sep 2026 19:39:14 +0100 Subject: [PATCH 03/13] Complete file path task --- Sprint-2/1-key-exercises/3-paths.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ab90ebb28..a31d6360f 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -11,13 +11,16 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; const lastSlashIndex = filePath.lastIndexOf("/"); +//console.log(lastSlashIndex); const base = filePath.slice(lastSlashIndex + 1); -console.log(`The base part of ${filePath} is ${base}`); +//console.log(base) +//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(".")); +console.log(dir); +console.log(ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 0ffcbc8ae0d6718ebdd47407c1ca5e63e43ba001 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Wed, 23 Sep 2026 19:09:14 +0100 Subject: [PATCH 04/13] Complete random number task --- Sprint-2/1-key-exercises/4-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..fac9ac6f2 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -2,7 +2,7 @@ const minimum = 1; const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; - +console.log(num); // 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 // It will help to think about the order in which expressions are evaluated From 8191573a5f7109ccb94bf7a3bbc3d0fbd2088d02 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Wed, 23 Sep 2026 23:36:36 +0100 Subject: [PATCH 05/13] // Comments are instructions or notes for humans. JavaScript ignores them and does not run them. --- Sprint-2/2-mandatory-errors/0.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..549a6df40 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,2 +1,5 @@ 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? + +// 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 3ff94aae45650b6477145921b5eea3175e10b8d1 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Thu, 24 Sep 2026 00:05:00 +0100 Subject: [PATCH 06/13] Fix age variable reassignment --- Sprint-2/2-mandatory-errors/1.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..f24faf922 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,4 +1,12 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +//const age = 33; +//age = age + 1; + +// We use let because the value of age needs to change. + + +let age = 33; + age = age + 1; +console.log(age); \ No newline at end of file From 1abe61a8579ab692f868658186af0f4af24eed61 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Thu, 24 Sep 2026 00:17:48 +0100 Subject: [PATCH 07/13] Fix cityOfBirth declaration order --- Sprint-2/2-mandatory-errors/2.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..2291af52f 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,5 +1,12 @@ // 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}`); +//console.log(`I was born in ${cityOfBirth}`); +//const cityOfBirth = "Bolton"; + +// Currently trying to print the string "I was born in Bolton" but it isn't working... +// what's the error ? + const cityOfBirth = "Bolton"; + +console.log(`I was born in ${cityOfBirth}`); \ No newline at end of file From 43b8618d1aa3b0ae08e61006cdaf99c478cad75b Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Thu, 24 Sep 2026 01:41:44 +0100 Subject: [PATCH 08/13] git commit -m "Fix card number slice error" --- Sprint-2/2-mandatory-errors/3.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..fce424031 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,5 +1,5 @@ -const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +//const cardNumber = 4533787178994213; +//const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +7,9 @@ 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 + +// I predict the code will give an error because cardNumber is a number, and slice() works on strings. +//const last4Digits = String(cardNumber).slice(-4); +const cardNumber = 4533787178994213; + +const last4Digits = String(cardNumber).slice(-4); From 8ca06db66e92658504fb6fce17dbd6bfdbadf304 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Thu, 24 Sep 2026 17:28:26 +0100 Subject: [PATCH 09/13] Complete percentage change interpretation --- .../1-percentage-change.js | 20 ++++++++++++++++--- 1 file changed, 17 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..ff2ab9ae4 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -2,13 +2,12 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.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 @@ -19,4 +18,19 @@ console.log(`The percentage change is ${percentageChange}`); // 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? +// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of thi e() and Number(). + +//a) There are 4 function calls. They are on lines 4 and 5. Each line contains two function calls: replaceAll() and Number(). +//b) The error comes from line 5. The replaceAll() function is missing a comma between its two arguments. The problem can be fixed by adding a comma: replaceAll(",", ""). +//priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +//c) The variable reassignment statements are lines 4 and 5. +//d) The variable declaration statements are lines 1, 2, 7 and 8. + +//e) The expression removes the comma from the price string and then converts the result from a string into a number, so JavaScript can use it for calculations. + +//carPrice = Number(carPrice.replaceAll(",", "")); +//priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); + +//const priceDifference = carPrice - priceAfterOneYear; +//const percentageChange = (priceDifference / carPrice) * 100; + From f56c69c4f7035e1bf4ff780208f86c425abf0498 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Thu, 24 Sep 2026 17:30:53 +0100 Subject: [PATCH 10/13] Complete percentage change interpretation --- Sprint-2/2-mandatory-errors/4.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..088aac62a 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,4 @@ const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +//const 24hourClockTime = "20:53"; +// I predict the code will give an error because a variable name cannot start with a number. +const twelveHourClockTime = "8:53pm"; \ No newline at end of file From cec8b9bab82fb4af8989a98501ddf217de1c5823 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Thu, 24 Sep 2026 18:27:54 +0100 Subject: [PATCH 11/13] Complete time format interpretation --- Sprint-2/3-mandatory-interpret/2-time-format.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 47d239558..872671bf6 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -23,3 +23,11 @@ console.log(result); // e) What do you think the variable result represents? Can you think of a better name for this variable? // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + +// a) There are 6 variable declarations. +// b) There is 1 function call. It is on line 10: console.log(result); +// c) The % operator gives the remainder after dividing movieLength by 60. +// c) The % operator gives the remainder after dividing movieLength by 60. 60 represents the number of seconds in one minute. +// d) It subtracts the remaining seconds from the movie length and then divides by 60 to convert the remaining seconds into total minutes. +// e) The variable result represents the movie duration in hours, minutes and seconds. A better name would be movieDuration. +// f) The code works for different positive values of movieLength because it converts seconds into hours, minutes and seconds. It expects movieLength to be a number representing seconds. From f86c3387ce5db5ea53c36b6e356aa3cad7b8dc38 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Fri, 25 Sep 2026 01:10:21 +0100 Subject: [PATCH 12/13] Complete pence to pounds interpretation --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..78e45e116 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,9 @@ 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 = ...: removes the final "p" from "399p", leaving "399" +// 3. padStart(3, "0"): makes sure the pence string has at least 3 characters by adding zeros to the beginning if needed. +// 4. const pounds = ...: takes all the characters except the last two, giving the pounds part of the price. +// 5. const pence = ...: takes the last two characters as the pence part and makes sure it has two characters. +// 6. console.log(`£${pounds}.${pence}`): displays the final price in pounds and pence format. \ No newline at end of file From bccc1dda2dd7582772164e0c629fbe27cf0285d3 Mon Sep 17 00:00:00 2001 From: Jestavo1 Date: Fri, 25 Sep 2026 05:09:14 +0100 Subject: [PATCH 13/13] Complete stretch explore exercises --- Sprint-2/4-stretch-explore/chrome.md | 3 +++ Sprint-2/4-stretch-explore/objects.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 962580b82..d721e81d3 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -13,3 +13,6 @@ Now try invoking the function `prompt` with a string input of `"What is your nam What effect does calling the `prompt` function have? What is the return value of `prompt`? +Calling the alert function displays a pop-up message to the user. + +Calling the prompt function asks the user for information. The return value of prompt is the information the user entered. diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index 0216dee56..f3e4fbfe5 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -9,7 +9,9 @@ What output do you get? Now enter just `console` in the Console, what output do you get back? Try also entering `typeof console` +The console stores an object containing functions and other properties used for interacting with the console. +The syntax console.log or console.assert accesses a function that belongs to the console object. The . means access a property or function that belongs to an object. Answer the following questions: What does `console` store?