From 9ec91faec01e907eca4b3ac70823d82f1bf36d80 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Sat, 19 Sep 2026 14:34:53 +0100 Subject: [PATCH 01/20] answer no 1 --- Sprint-2/1-key-exercises/1-count.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..626f9abd8 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/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 is an assignment statement that adds 1 to the current value of count and assigns the result back to count \ No newline at end of file From 0f2dba2233fcaf6fab4eda20377ff83e30940c07 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Sat, 19 Sep 2026 16:30:45 +0100 Subject: [PATCH 02/20] Answer no 1.2 --- Sprint-2/1-key-exercises/2-initials.js | 4 +++- 1 file changed, 3 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..a9a421766 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,6 +5,8 @@ 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); // "CKJ" + // https://www.google.com/search?q=get+first+character+of+string+mdn From 12ae08697ea21e8e44b31ac0969dc54da22c083d Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 10:54:07 +0100 Subject: [PATCH 03/20] answer no 1.3 --- Sprint-2/1-key-exercises/3-paths.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ab90ebb28..47ad2aa21 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -17,7 +17,8 @@ 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 + 1); +const ext = filePath.slice(filePath.lastIndexOf(".")); +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 From 3b7ed1e45dd04912b9fc03e1227a9d239dc5ddee Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 12:21:48 +0100 Subject: [PATCH 04/20] answer no 1.4 --- Sprint-2/1-key-exercises/4-random.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..33653994c 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -7,3 +7,4 @@ 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); \ No newline at end of file From 4c1906d50a61c96a772e1af738d69a8f00c7e8d3 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 12:31:25 +0100 Subject: [PATCH 05/20] answer no 1.3 e --- Sprint-2/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 47ad2aa21..6ad8a935e 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -17,8 +17,8 @@ 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 = filePath.slice(0, lastSlashIndex + 1); +const dir = filePath.slice(0, lastSlashIndex); const ext = filePath.slice(filePath.lastIndexOf(".")); 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 +// https://www.google.com/search?q=slice+mdn From 7c6ce2c49728ece0bda9535a093d59bffa2383e5 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 13:42:32 +0100 Subject: [PATCH 06/20] answer 2.1 --- Sprint-2/2-mandatory-errors/0.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..486d5244d 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,2 +1,4 @@ -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 373d3aae24856b8222bbdd89a839538e51d94daa Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 14:20:12 +0100 Subject: [PATCH 07/20] answer no 1.1 --- Sprint-2/2-mandatory-errors/1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..be9fa8416 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -2,3 +2,5 @@ const age = 33; age = age + 1; + +console.log(age); \ No newline at end of file From 550150b06d6d45d2ea163975f751716bd462105d Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 14:24:32 +0100 Subject: [PATCH 08/20] answer no 2.1 --- Sprint-2/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index be9fa8416..7df90a0aa 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,6 +1,7 @@ // 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 d03f49ed87f3bc31cc360873163d47a001e64aac Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 14:40:27 +0100 Subject: [PATCH 09/20] answer 2.2 --- Sprint-2/2-mandatory-errors/2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..66fb4ddaa 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -3,3 +3,9 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +The error in the code is that the variable `cityOfBirth` is being used before it is declared and assigned a value. In JavaScript, variables declared with `const` (or `let`) are not hoisted in the same way as `var`, meaning they cannot be accessed before their declaration. + +const cityOfBirth = "Bolton"; + +console.log(`I was born in ${cityOfBirth}`); \ No newline at end of file From 3bc535d950f4e43c9b1ff274119dfc9e00d0cbc0 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 14:54:37 +0100 Subject: [PATCH 10/20] answer 2.2 e --- Sprint-2/2-mandatory-errors/2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index 66fb4ddaa..3aa83c9fa 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -4,7 +4,9 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; -The error in the code is that the variable `cityOfBirth` is being used before it is declared and assigned a value. In JavaScript, variables declared with `const` (or `let`) are not hoisted in the same way as `var`, meaning they cannot be accessed before their declaration. +The error in the code is that the variable `cityOfBirth` is being used before it is declared and assigned a value. + +The Corrected code should be as follows: const cityOfBirth = "Bolton"; From ce89afe805d2224868133b6efcff9c5f6c5da091 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 15:24:24 +0100 Subject: [PATCH 11/20] answer 2.3 --- Sprint-2/2-mandatory-errors/3.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..49154fa8d 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -7,3 +7,8 @@ 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 + +Convert cardNumber to a string before using .slice(): +const cardNumber = 4533787178994213; +const last4Digits = String(cardNumber).slice(-4); +console.log(last4Digits); \ No newline at end of file From 83dd7a049f3ad73f7ffa8aac9bc4297a12302ebb Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 15:34:19 +0100 Subject: [PATCH 12/20] answer 2.4 --- Sprint-2/2-mandatory-errors/4.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..2b2c1309d 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,11 @@ const 12HourClockTime = "8:53pm"; + const 24hourClockTime = "20:53"; + + +The error is JavaScript variable names cannot start with a number + +The corrected code should be as follows: + +const twelveHourClockTime = "8:53pm"; +const twentyFourHourClockTime = "20:53"; \ No newline at end of file From d008b71e5fe2cfecc0d23a79429de648f70a5969 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 16:01:00 +0100 Subject: [PATCH 13/20] answer 3.1 --- .../1-percentage-change.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 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..c26ca2d92 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -9,14 +9,18 @@ const percentageChange = (priceDifference / carPrice) * 100; console.log(`The percentage change is ${percentageChange}`); -// Read the code and then answer the questions below +The error is on this line: -// a) How many function calls are there in this file? Write down all the lines where a function call is made +There is a missing comma between "," and "". -// 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(",", "")); -// c) Identify all the lines that are variable reassignment statements +Final corrected code is going to be: -// 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? +let carPrice = "10,000"; +let priceAfterOneYear = "8,543"; +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +const priceDifference = carPrice - priceAfterOneYear; +const percentageChange = (priceDifference / carPrice) * 100; +console.log(`The percentage change is ${percentageChange}`); From b6b34090461c45995f0e96c6be48bf0bd15c62b5 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 16:48:40 +0100 Subject: [PATCH 14/20] answer 2.3 e --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index c26ca2d92..e47d21fe1 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -24,3 +24,4 @@ priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; console.log(`The percentage change is ${percentageChange}`); + From ebba807550785b0c53eda67013ff8336dad39d5f Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 17:03:33 +0100 Subject: [PATCH 15/20] answer 3.2 --- Sprint-2/3-mandatory-interpret/2-time-format.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 47d239558..e1e419927 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -16,10 +16,23 @@ console.log(result); // b) How many function calls are there? // c) Using documentation, explain what the expression movieLength % 60 represents -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators // d) Interpret line 4, what does the expression assigned to totalMinutes mean? // 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 + +// answers + +// a) 6 variable declarations + +// b) 1 function call + +// c) % gives the remainder after division. movieLength % 60 gives the remaining seconds + +// d) It removes the remaining seconds and converts the rest from seconds into minutes + +// e) It represents the movie duration as hours:minutes:seconds. A better name is movieDuration + +// f) It works for positive whole numbers representing seconds, but not all possible values From e9cb419f6444e13c87fd3d7846ffa7a4a6a1d7b2 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 17:05:01 +0100 Subject: [PATCH 16/20] answer 2.3 e --- Sprint-2/2-mandatory-errors/3.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index 49154fa8d..a8fb4ad56 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -8,7 +8,7 @@ const last4Digits = cardNumber.slice(-4); // 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 -Convert cardNumber to a string before using .slice(): -const cardNumber = 4533787178994213; -const last4Digits = String(cardNumber).slice(-4); -console.log(last4Digits); \ No newline at end of file +// Convert cardNumber to a string before using .slice(): +// const cardNumber = 4533787178994213; +// const last4Digits = String(cardNumber).slice(-4); +// console.log(last4Digits); \ No newline at end of file From 6b08bbc2d31eee43254700b27fae90c04a26343b Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 17:14:15 +0100 Subject: [PATCH 17/20] answer 3.3 --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 14 ++++++++++++++ 1 file changed, 14 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..22d35516f 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,17 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" + +// Answer + +// penceString = "399p" — stores the price as a string + +// penceStringWithoutTrailingP — removes the final "p", giving "399" + +// paddedPenceNumberString — adds leading zeros if necessary so the string has at least 3 digits. + +// pounds — takes all the characters except the last two, giving "3" + +// pence — takes the last two characters, giving "99", and ensures there are two digits + +// console.log — combines the pounds and pence and displays £3.99 \ No newline at end of file From d4b38045d4ed3825f955abf76bc51c7a3aa4caa3 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 17:26:06 +0100 Subject: [PATCH 18/20] answer 4.1 --- Sprint-2/4-stretch-explore/chrome.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 962580b82..c7f97cba4 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -13,3 +13,12 @@ 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`? + +Answer + +alert() displays a pop-up message to the user. + +prompt() displays a pop-up asking the user to enter some text. + +prompt() returns the text entered by the user. If the user clicks Cancel, +it returns null. From 3298c3366a35b0d290dab598d73f2fc8de9bba0a Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 17:33:06 +0100 Subject: [PATCH 19/20] answer 4.4 --- Sprint-2/4-stretch-explore/objects.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index 0216dee56..1ddf04ed6 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -14,3 +14,23 @@ Answer the following questions: What does `console` store? What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? + +Answer + +When I enter `console.log` in the Chrome DevTools Console, it shows the `log` function. + +When I enter `console`, it shows an object containing different properties and methods, such as `log`, `error`, `warn`, and `assert`. + +When I enter `typeof console`, the output is `"object"`. + +What does `console` store? + +`console` stores an object that contains methods used to interact with the browser's developer console, such as `log()`, `error()`, `warn()`, and `assert()`. + +What does `console.log` or `console.assert` mean? + +The `.` is used to access a property or method that belongs to an object. + +For example, `console.log` means accessing the `log` method that belongs to the `console` object. Similarly, `console.assert` accesses the `assert` method of the `console` object. + +So, the `.` basically means "access something that belongs to this object." From 9a3a41297a7884533a9fe257013e5c2bb754ef60 Mon Sep 17 00:00:00 2001 From: Selamawit Abay Date: Mon, 21 Sep 2026 17:39:03 +0100 Subject: [PATCH 20/20] answer 3.1 e --- .../1-percentage-change.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index e47d21fe1..efef54d9b 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -1,27 +1,27 @@ -let carPrice = "10,000"; -let priceAfterOneYear = "8,543"; +// let carPrice = "10,000"; +// let priceAfterOneYear = "8,543"; -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +// carPrice = Number(carPrice.replaceAll(",", "")); +// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); -const priceDifference = carPrice - priceAfterOneYear; -const percentageChange = (priceDifference / carPrice) * 100; +// const priceDifference = carPrice - priceAfterOneYear; +// const percentageChange = (priceDifference / carPrice) * 100; -console.log(`The percentage change is ${percentageChange}`); +// console.log(`The percentage change is ${percentageChange}`); -The error is on this line: +// The error is on this line: -There is a missing comma between "," and "". +// There is a missing comma between "," and "". -priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +// priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); -Final corrected code is going to be: +// Final corrected code is going to be: -let carPrice = "10,000"; -let priceAfterOneYear = "8,543"; -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); -const priceDifference = carPrice - priceAfterOneYear; -const percentageChange = (priceDifference / carPrice) * 100; -console.log(`The percentage change is ${percentageChange}`); +// let carPrice = "10,000"; +// let priceAfterOneYear = "8,543"; +// carPrice = Number(carPrice.replaceAll(",", "")); +// priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +// const priceDifference = carPrice - priceAfterOneYear; +// const percentageChange = (priceDifference / carPrice) * 100; +// console.log(`The percentage change is ${percentageChange}`);