From 2d00395b40df2ba9faa18a7829578f7995fdb684 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Sun, 7 Dec 2025 00:41:04 +0100 Subject: [PATCH 01/36] creating the count variables --- 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 117bcb2b6e..823f33513b 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 + +console.log(count); \ No newline at end of file From 9c52823445c4893d85ca84de2db5df3453c34068 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Sun, 7 Dec 2025 00:45:49 +0100 Subject: [PATCH 02/36] declared variable called initials --- Sprint-1/1-key-exercises/2-initials.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..7d103add57 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,9 @@ 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[0] + middleName[0] + lastName[0]`; + +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From 3f23c0faf5bb79912f1e97165cb706f01d67d07b Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Sun, 7 Dec 2025 01:10:15 +0100 Subject: [PATCH 03/36] variables to store dir created --- Sprint-1/1-key-exercises/3-paths.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..c0440e0430 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -10,14 +10,15 @@ // (All spaces in the "" line should be ignored. They are purely for formatting.) const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; + const lastSlashIndex = filePath.lastIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); + 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 = ; - -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +const dir = filePath.slice(0, lastSlashIndex + 1); +const lastDotIndex = filePath.lastSlashIndexOf("."); +const ext = filePath.slice(lastDotIndex); \ No newline at end of file From 50324714d8586d42833e2ea96487696bf985b4d6 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Sun, 7 Dec 2025 16:10:34 +0100 Subject: [PATCH 04/36] line 3 was assign a variable while the equal sign is an assignment operator --- 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 823f33513b..39d82bcdbd 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,5 +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 is reassigning the variable +// The equal sign is an assignment operator console.log(count); \ No newline at end of file From 166d059a94a42accb56c65c32cf9ab7b48d4d7f3 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 09:54:58 +0100 Subject: [PATCH 05/36] created a variable that store the first character of each string --- Sprint-1/1-key-exercises/2-initials.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 7d103add57..46958ce3fa 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 = `firstName[0] + middleName[0] + lastName[0]`; +let initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0) console.log(initials); From 02524c7a131288b4de3feacabecfa10ea551539a Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 11:34:24 +0100 Subject: [PATCH 06/36] variable to store the ext part was created --- Sprint-1/1-key-exercises/3-paths.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index c0440e0430..c965ed80e0 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -14,11 +14,15 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; const lastSlashIndex = filePath.lastIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); -console.log(`The base part of ${filePath} is ${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 +let indexOfTheBase = base.lastIndexOf(".") +console.log(base); + +let ext = base.slice(indexOfTheBase); +console.log(ext); +console.log("-----------------------------------------------------------") + +// Create a variable to store the dir part of the filePath variable -const dir = filePath.slice(0, lastSlashIndex + 1); -const lastDotIndex = filePath.lastSlashIndexOf("."); -const ext = filePath.slice(lastDotIndex); \ No newline at end of file From 472a966b792cc2169aa35f3190fb0658ecd8d2e1 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 11:37:14 +0100 Subject: [PATCH 07/36] defining the path to dir --- Sprint-1/1-key-exercises/3-paths.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index c965ed80e0..37fe695dc6 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -25,4 +25,11 @@ console.log(ext); console.log("-----------------------------------------------------------") // Create a variable to store the dir part of the filePath variable +console.log(filePath) +console.log(lastSlashIndex) + +let pathToDir = filePath.slice(0, lastSlashIndex) +console.log(pathToDir) + + From 169e02f46848bb26dd2c25ca1c63aeef50cce423 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 11:39:36 +0100 Subject: [PATCH 08/36] variable to store dir part created --- Sprint-1/1-key-exercises/3-paths.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 37fe695dc6..4cb0af6ca9 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -31,5 +31,9 @@ console.log(lastSlashIndex) let pathToDir = filePath.slice(0, lastSlashIndex) console.log(pathToDir) +let indexOfDir = pathToDir.lastIndexOf("/") +console.log(indexOfDir) +let dir = pathToDir.slice(indexOfDir + 1) +console.log(dir) From 70e4f2b07197de2805bc1d7a7ec58e01cd9deaac Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 12:25:52 +0100 Subject: [PATCH 09/36] num is being defing --- Sprint-1/1-key-exercises/4-random.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..dbb05a78f5 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/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) From 6c502789b3813bd427552cbb4faf59f834afdbd8 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 12:59:05 +0100 Subject: [PATCH 10/36] single-line comment marker was added to make it a valid javascript syntax --- Sprint-1/2-mandatory-errors/0.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..e1b1225b71 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/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 +// 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? + +// this text is not a valid javascript syntax, which could cause a syntaxError +// to fix this, a single-line comment marker (//) should be at the beginning of each line. \ No newline at end of file From 9f97c7917d591ca538c69674306d98d47384af9c Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 13:09:05 +0100 Subject: [PATCH 11/36] able to find out what the num is --- Sprint-1/1-key-exercises/4-random.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index dbb05a78f5..4e91ec1de0 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -8,3 +8,6 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // 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) +console.log(`Minimum: ${minimum}`); +console.log(`Maximum: ${maximum}`); +console.log(`Generated random number (num): ${num}`); \ No newline at end of file From 68a3b10c56ae1eeaff29cc3433b593862cf57f51 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 14:19:03 +0100 Subject: [PATCH 12/36] the variable was change from const to let to have a valid reassignment --- Sprint-1/2-mandatory-errors/1.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea76..3970ff0a65 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,10 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; -age = age + 1; +// const age = 33; +// age = age + 1; + +// To do this i will change "const" to "let" +let age = 33; +age = age + 1; // This value is now a valid reassignment + +console.log(age) From 45f51c3f9eeadc58121aa3bf7f43c5bdfa7c748d Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 14:44:43 +0100 Subject: [PATCH 13/36] a referenceErroe was detected on the code --- Sprint-1/2-mandatory-errors/2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831d..5530e3f9af 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,9 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +// The error here is referenceError +// To fix this, the declaration will have to move to the top + +// const cityOfBirth = "Bolton"; +// console.log(`I was born in ${cityOfBirth}`) From f5704cec3901c648f2f8428a0c6cebca6c875471 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 15:43:15 +0100 Subject: [PATCH 14/36] the typeError is identify --- Sprint-1/2-mandatory-errors/3.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884db..28b98448df 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -7,3 +7,6 @@ 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 + +// JavaScript treats the cardNumber variable as a number primitive. The .slice() method, which is used to extract a section of a sequence, is exclusively available on string and array objects. +// The console output here´s TypeError: cardNumber.slice is not a function \ No newline at end of file From 31af3fa152e8709dcd9b6fd54809050b5471e416 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 15:47:24 +0100 Subject: [PATCH 15/36] my prediction was correct, the core problem is .slice --- Sprint-1/2-mandatory-errors/3.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index 28b98448df..3030980c52 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -9,4 +9,6 @@ const last4Digits = cardNumber.slice(-4); // Then try updating the expression last4Digits is assigned to, in order to get the correct value // JavaScript treats the cardNumber variable as a number primitive. The .slice() method, which is used to extract a section of a sequence, is exclusively available on string and array objects. -// The console output here´s TypeError: cardNumber.slice is not a function \ No newline at end of file +// The console output here´s TypeError: cardNumber.slice is not a function +// Yes, the prediction was essentially correct. The core problem is that .slice(). +// The Number object does not have a method named slice. JavaScript reserves this method for sequences like strings and arrays. \ No newline at end of file From fe1a597ca8045f9ab497f6e6460c925891023a35 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 15:54:00 +0100 Subject: [PATCH 16/36] converting the number to a string using tostring() before using the slice --- Sprint-1/2-mandatory-errors/3.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index 3030980c52..413f21a094 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/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 @@ -11,4 +11,10 @@ const last4Digits = cardNumber.slice(-4); // JavaScript treats the cardNumber variable as a number primitive. The .slice() method, which is used to extract a section of a sequence, is exclusively available on string and array objects. // The console output here´s TypeError: cardNumber.slice is not a function // Yes, the prediction was essentially correct. The core problem is that .slice(). -// The Number object does not have a method named slice. JavaScript reserves this method for sequences like strings and arrays. \ No newline at end of file +// The Number object does not have a method named slice. JavaScript reserves this method for sequences like strings and arrays. + +// Fix +const cardNumber = 4533787178994213; +const last4Digits = cardNumber.toString().slice(-4) + +console.log(last4Digits) \ No newline at end of file From 252b75d8af894dd2b7e87ebadfdede83ac8a0dfe Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 18:55:58 +0100 Subject: [PATCH 17/36] a syntaxError was identified and i have to renamed the variable to start with a letter --- Sprint-1/2-mandatory-errors/4.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d1..d6b29566ef 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,9 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +// const 12HourClockTime = "20:53"; // Error: variable name can not start with a number +// const 24hourClockTime = "08:53"; // Error: variable name can not start with a number + + +// This is a syntaxError: invalid or unexpected token +// To start, the Variable has to be renamed with a letter on both + +const time24Hour = "20:53"; +const time12Hour = "08:53"; \ No newline at end of file From b76abce7513006c8ff323ba1633438cd88ede69c Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 19:09:00 +0100 Subject: [PATCH 18/36] the structure of data conversion --- Sprint-1/2-mandatory-errors/4.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index d6b29566ef..c8a5f77a5d 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -6,4 +6,10 @@ // To start, the Variable has to be renamed with a letter on both const time24Hour = "20:53"; -const time12Hour = "08:53"; \ No newline at end of file +const time12Hour = "08:53"; + +// To structure the data for conversion (demonstrating the logic) +const thisIs24HourTime = "20:53"; + +// To convert 20:53 (8:53 PM), you'd need logic: +const thisIs12HourTime = "08:53 PM"; From d9bdbed08afb46c5ec0494f7f98fc0c84bb1e809 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 19:14:14 +0100 Subject: [PATCH 19/36] output of the 24HourTime --- Sprint-1/2-mandatory-errors/4.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index c8a5f77a5d..98598dbc96 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -12,4 +12,6 @@ const time12Hour = "08:53"; const thisIs24HourTime = "20:53"; // To convert 20:53 (8:53 PM), you'd need logic: -const thisIs12HourTime = "08:53 PM"; +const thisIs12HourTime = "08:53 PM"; + +console.log(`24-Hour Time: ${thisIs24HourTime}`); \ No newline at end of file From 0c581d3c8e1f30115b4c42feef6e39842d9c1855 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 19:19:19 +0100 Subject: [PATCH 20/36] output data of the thisIs12HourTime --- Sprint-1/2-mandatory-errors/4.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 98598dbc96..1dd7ebad5f 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -14,4 +14,5 @@ const thisIs24HourTime = "20:53"; // To convert 20:53 (8:53 PM), you'd need logic: const thisIs12HourTime = "08:53 PM"; -console.log(`24-Hour Time: ${thisIs24HourTime}`); \ No newline at end of file +console.log(`24-Hour Time: ${thisIs24HourTime}`); +console.log(`12-Hour Time: ${thisIs12HourTime}`); \ No newline at end of file From abe97244a07633a137d693f0752b5eb432b76d19 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 21:28:15 +0100 Subject: [PATCH 21/36] identifying the functional call in the file --- .../3-mandatory-interpret/1-percentage-change.js | 12 ++++++++++++ 1 file changed, 12 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..a41feeea66 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,8 +12,20 @@ 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 functional call in this file, and they´re on the following line: Line 4: replaceAll, Line 5: replaceAll, Line 10: console.log +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +Number(...), carPrice.replaceAll(...) +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? +/*After running the code, the error is identified in line 5: +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +The error is a SyntaxError because the arguments for the replaceAll() method are not correctly separated. It should be replaceAll(searchValue, replaceValue). +*/ +//To fix insert the required comma separator +/* priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // c) Identify all the lines that are variable reassignment statements From 6afd7318e9d4eee8f83835388b3965830c77ae02 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 21:45:12 +0100 Subject: [PATCH 22/36] identified line 4 and 5 as the variable reassigned statement --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index a41feeea66..60d38d85dd 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -2,7 +2,7 @@ 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; @@ -24,10 +24,13 @@ console.log(\The percentage change is ${percentageChange}`);`*/ priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); The error is a SyntaxError because the arguments for the replaceAll() method are not correctly separated. It should be replaceAll(searchValue, replaceValue). */ -//To fix insert the required comma separator -/* priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +//To fix insert the required comma separator: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // c) Identify all the lines that are variable reassignment statements +/* Variable reassignment statements change the value of an already declared variable. +The lines that are variable reassignment statement are; +line 4: carPrice = Number(carPrice.replaceAll(",", "")); +line 5: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); */ // d) Identify all the lines that are variable declarations From 9c66b34b037cc23fdfb9b074d6db0bd97c7f0f3a Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 21:49:06 +0100 Subject: [PATCH 23/36] line 4 and 5 was identified as variable reassignment statement --- 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 60d38d85dd..ae71f15fc6 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -28,6 +28,7 @@ The error is a SyntaxError because the arguments for the replaceAll() method are // c) Identify all the lines that are variable reassignment statements /* Variable reassignment statements change the value of an already declared variable. +This is possible because both variables were declared "let" The lines that are variable reassignment statement are; line 4: carPrice = Number(carPrice.replaceAll(",", "")); line 5: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); */ From aa235bccba512c843ef29341ee0752508b9e5778 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 22:02:50 +0100 Subject: [PATCH 24/36] this is were all the variable declaration line was identified --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index ae71f15fc6..1faf4ebe02 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -34,5 +34,12 @@ line 4: carPrice = Number(carPrice.replaceAll(",", "")); line 5: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); */ // d) Identify all the lines that are variable declarations +/* This is were new variables are introduce into the scope using "let" or "const". +the following lines are stated to be variable declared; +line 1: "let carPrice" +line 2: "let priceAfterOneYear" +line 7: "const priceDifference" +line 8: "const percentageChange" */ // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + \ No newline at end of file From c8984aa913ca686a6494ec8ad7733b1c222801fd Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 22:34:23 +0100 Subject: [PATCH 25/36] describing the expression number --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 8 +++++++- 1 file changed, 7 insertions(+), 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 1faf4ebe02..a18549ffc3 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -42,4 +42,10 @@ line 7: "const priceDifference" line 8: "const percentageChange" */ // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? - \ No newline at end of file +/* This expression Number(carPrice.replaceAll(",", "")) is performing data cleaning and type conversion. +carPrice.replaceAll(",", ""): this is the string method, that searches the string stored in carPrice(10,000) for all the occurrences of the comma character (,) +and then replace it with an empty string (""). +The second part is a builth-in function Number(...), that attempt to convert the resulting clean string ("10000") into numeric data type. +*/ + +/* The main purpose is to take a price string formatted for human reading and then convert it into valid number type (10000) so that mathematical calculation can be performed correctly.*/ \ No newline at end of file From ba0bc21991558838766d8ad96cf3b35c25fdebad Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 22:46:39 +0100 Subject: [PATCH 26/36] printing the string using console.log --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index a18549ffc3..5cf038c938 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -8,6 +8,10 @@ const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; console.log(`The percentage change is ${percentageChange}`); +console.log(carPrice) +console.log(priceAfterOneYear) +console.log(priceDifference) +console.log(percentageChange) // Read the code and then answer the questions below From 44ee43e53a9845eab98fe37a357afffd445f36f1 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Mon, 8 Dec 2025 23:11:42 +0100 Subject: [PATCH 27/36] the number of variable declaration was listed --- Sprint-1/3-mandatory-interpret/2-time-format.js | 8 ++++++++ 1 file changed, 8 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..9b9ec355b2 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,6 +12,14 @@ 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? +/* In this program, there are six variable declaration, +the list is as follows: +i. const movieLength, +ii. const remainingSeconds +iii. const totalMinutes +iv. const remainingMinutes +v. const totalHours +vi. const result */ // b) How many function calls are there? From a5f55e7d51ad2e53e1c50d616120d631c020a0fd Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 9 Dec 2025 08:20:17 +0100 Subject: [PATCH 28/36] my interpretation of line 4: const totalMinutes --- Sprint-1/3-mandatory-interpret/2-time-format.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 9b9ec355b2..988227d34a 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -8,6 +8,11 @@ const totalHours = (totalMinutes - remainingMinutes) / 60; const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; console.log(result); +console.log(movieLength) +console.log(remainingSeconds) +console.log(totalMinutes) +console.log(remainingMinutes) +console.log(totalHours) // For the piece of code above, read the code and then answer the following questions @@ -22,12 +27,20 @@ v. const totalHours vi. const result */ // b) How many function calls are there? +/* There is only 1 function call in the program and the call 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 +/* This computes the remainder left over when one operand (movieLength) is divided by a second operand (60) +It is the number of seconds remaining after the total second (movieLength) have been converted into whole minute. +meanwhile they are 60 seconds in a minute, dividing by 60 and taking the remainder will give the seconds that don´t make up a full minute. */ // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +/* Line 4 is const totalMinutes = (movieLength - remainingSeconds) / 60; +The expression calculates the total number of whole minutes contained in the (movieLength) +i.e movieLength - remainingSeconds which subtraction removes the partial seconds, then leaving a value that is divisible perfectly by 60. +(...) / 60; This division converts the total seconds into total minutes. */ // 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 From f6abfc6ec88f7e936488543f27006fb127cf1651 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 9 Dec 2025 08:29:08 +0100 Subject: [PATCH 29/36] giving a better name for this variable --- Sprint-1/3-mandatory-interpret/2-time-format.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 988227d34a..ac31892383 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -41,6 +41,9 @@ The expression calculates the total number of whole minutes contained in the (mo i.e movieLength - remainingSeconds which subtraction removes the partial seconds, then leaving a value that is divisible perfectly by 60. (...) / 60; This division converts the total seconds into total minutes. */ + // e) What do you think the variable result represents? Can you think of a better name for this variable? +/* The variable result represent the movie duration formatted as a time string in the structure Hours:Minutes:Seconds ("2:26:24"). +A better descriptive name for this variable for me would be "timeString". */ // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer From 9222bb73a8dfae4737246a6bd066bcf0c9abf283 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 9 Dec 2025 08:50:05 +0100 Subject: [PATCH 30/36] experimenting with different values of movieLength --- Sprint-1/3-mandatory-interpret/2-time-format.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index ac31892383..8bf35c2aa5 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -47,3 +47,8 @@ i.e movieLength - remainingSeconds which subtraction removes the partial seconds A better descriptive name for this variable for me would be "timeString". */ // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +/* No, this code will not work well for all values of movieLength, specifically for displaying the time correctly. +If any component (totalHours, remainingMinutes, or remainingSeconds) is less than 10, the output will look unusual. +The conversion logic is mathematically sound, but the final output format is unreliable because it does not include padding (leading zeros). +For short movie; If movieLength = 65 seconds, the result is "0:1:5" (0 hours, 1 minute, 5 seconds). This is usually expected to be displayed as "00:01:05". +The expression const result = \${totalHours}:${remainingMinutes}:${remainingSeconds}`;uses simple string interpolation.*/ \ No newline at end of file From 5a5f8a132448137b19d639ddca6eee43a21b9e1e Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 9 Dec 2025 08:52:37 +0100 Subject: [PATCH 31/36] edited the number of functional call --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 8bf35c2aa5..3872491e77 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -27,7 +27,7 @@ v. const totalHours vi. const result */ // b) How many function calls are there? -/* There is only 1 function call in the program and the call is console.log(result)*/ +/* There is only 6 function call in the program and the call 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 From efa4e804cbdb65e3a51860f677752a3515a0f1fe Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 9 Dec 2025 23:15:04 +0100 Subject: [PATCH 32/36] describing the purpose the brea kdown of each line in this program --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 14 ++++++++++++++ 1 file changed, 14 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..d704a609dc 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/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" + +// 3. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length -1); +// cleaning the trailing P character. it uses the string´s length minus 1 as the end index for substring(), this leave only the numeric value while drop the last character. + +// 8. const paddedPenceNumberString = penceStringWithoutTrailingP.padStar(3, "0"); Padding- ensure the numeric string is at least three characters long by prepending zeros. +// this is important for separating pounds from pence especially when values is less than 100p + +// 9. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); Extracting pounds component, this uses substring() +// to take all character from the start (index 0) up to, but not including the last two characters, they are always pence. + +// 14. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); Extracting and formatting price- +// Extracts the pence component (the last two digits) and ensures they are always two digits long by padding the end with a zero if needed (though not needed for "99"). + +// 18. console.log(\£${pounds}.${pence}`);` Output: Format the extracted components into the standard currency display £3.99. \ No newline at end of file From ccb5810e18fda3d3eca17936363c2315388beb5f Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 9 Dec 2025 23:56:44 +0100 Subject: [PATCH 33/36] the effect i got for calling prompt --- Sprint-1/4-stretch-explore/chrome.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feafe..c71ecc2ec7 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? +// A pop-up window appears in the browser window, displaying the message "Hello world" along with a button "Ok". 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? +// A pop-up dialog box appears in the browser window. This box displays the message "What is your name?" and contains a text input field along with "OK" and "Cancel" buttons. This dialog requires user interaction (typing text and clicking a button) before the browser can proceed. + What is the return value of `prompt`? +// when i type my name "Ifeyinwa Ofulue", the return value of the prompt was "Ifeyinwa Ofulue". From 7938276c44f88f2c7d23fc749cf0d8c890154533 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Wed, 10 Dec 2025 00:28:53 +0100 Subject: [PATCH 34/36] exploring some more concepts that from the devtools --- Sprint-1/4-stretch-explore/objects.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56a..2760eaca7e 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,36 @@ 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? +// I got the output; f log() ((native code)) Now enter just `console` in the Console, what output do you get back? +// I got quite number of output; { + assert: f assert() + clear: f clear() + count: f count() + countReset: f countReset() + info: f info() + log: f log() + profile: f profile() + table: f table() + and many more. +} Try also entering `typeof console` +// I got the output: "object" Answer the following questions: What does `console` store? +// The variable console stores a reference to a global Host Object provided by the browser environment. This object is a container (or dictionary) that holds a collection of methods (functions) + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +// The syntax represents Property Access on an object. + +console: is the object itself. + +. (Dot Notation): The dot (.) is the Member Access Operator. It tells the JavaScript engine to look inside the console object for a specific property. + +log or assert: These are the properties (or keys) of the console object. Since these properties hold functions as their values, they are specifically referred to as methods of the console object. + +// In otherwords, console.log means: Access the property named log that resides inside the console object. From 28de569e0864781e2b3b96f097ef123c6b8a7bc8 Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 23 Dec 2025 21:07:25 +0100 Subject: [PATCH 35/36] the declaration was move to the top --- Sprint-1/2-mandatory-errors/2.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index 5530e3f9af..15f461aeb8 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,11 +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}`); -const cityOfBirth = "Bolton"; +// console.log(`I was born in ${cityOfBirth}`); +// const cityOfBirth = "Bolton"; // The error here is referenceError // To fix this, the declaration will have to move to the top -// const cityOfBirth = "Bolton"; -// console.log(`I was born in ${cityOfBirth}`) +const cityOfBirth = "Bolton"; + +console.log(`I was born in ${cityOfBirth}`); From 60c694ec9161b20f90b5f5131fb219b71dea469f Mon Sep 17 00:00:00 2001 From: Ifeyinwa Date: Tue, 23 Dec 2025 21:13:02 +0100 Subject: [PATCH 36/36] the declaration was move to the top --- Sprint-1/2-mandatory-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index 15f461aeb8..f74a930e2f 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -9,4 +9,4 @@ const cityOfBirth = "Bolton"; -console.log(`I was born in ${cityOfBirth}`); +console.log(`I was born in ${cityOfBirth}`); \ No newline at end of file