From d3add85129e4e3fe993f769cbf8c283159a07d71 Mon Sep 17 00:00:00 2001 From: FarancisGH Date: Sun, 15 Feb 2026 18:38:55 +0000 Subject: [PATCH 1/4] Changes done on Sprint-1/1-key-exercise 1-4. --- Sprint-1/1-key-exercises/1-count.js | 1 + Sprint-1/1-key-exercises/2-initials.js | 3 ++- Sprint-1/1-key-exercises/3-paths.js | 9 ++++++--- Sprint-1/1-key-exercises/4-random.js | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..166df2a50 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/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 +//This means that increase the count number by 1 (by adding 1 to the initial number) and maintain the count value after adding 1. E.g 0+1 =1, so the new count now will be 1. \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..b0f18e6c2 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,8 @@ 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]; // https://www.google.com/search?q=get+first+character+of+string+mdn +console.log (initials); diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..527a94785 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,10 @@ 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 lastDotIndex = filePath.lastIndexOf("."); +const ext = filePath.slice(lastDotIndex); + +// https://www.google.com/search?q=slice+mdn + -// https://www.google.com/search?q=slice+mdn \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..7cc8f3224 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,19 @@ 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 + + +//ANSWERS: +// Num represents a random whole number(integers). In which in this case it can be between 1 to 100. +//Now let me break it down; + +//This const minimum = 1; and this const maximum = 100; represent the range from which i want my random numbers to come from. + +//This command Math.random() generates a random decimal number from 0(being inclusive) to 1(but not inclusing 1) e.g 0.23, 0.87, 0.001 or 0.999 but it will never generate 1. +// This command (maximum - minimum + 1) is a calculation of the Maximum and Minimum number i.e, 100-1+1=100 +// This command Math.floor helps to remove any decimal point and round numbers down to the nearest whole number. e.g from 45.9 to 45 +// This command +Minimum helps to add the minimum number in our range inorder to increase the numbers to 100(incusive) + +console.log (num) + +//After logging and running num, I had these series of numbers: 12, 66, 36,64,9,91.... \ No newline at end of file From e2cd279d226b083e300b7a2e758267031129ee94 Mon Sep 17 00:00:00 2001 From: FarancisGH Date: Wed, 18 Feb 2026 13:40:40 +0000 Subject: [PATCH 2/4] Corrections and Changes made on Sprint-1/2-mandatory-errors --- Sprint-1/1-key-exercises/1-count.js | 1 - Sprint-1/2-mandatory-errors/0.js | 8 ++++++-- Sprint-1/2-mandatory-errors/1.js | 7 ++++++- Sprint-1/2-mandatory-errors/2.js | 4 +++- Sprint-1/2-mandatory-errors/3.js | 7 ++++++- Sprint-1/2-mandatory-errors/4.js | 9 +++++++-- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 166df2a50..c013f99e9 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,5 +1,4 @@ let count = 0; - count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..efec9ebcb 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,6 @@ -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? + +//Answer: + +//By turning them into comments(by using //) just like this setence. \ 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..26a743d59 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,9 @@ // 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); + + +//I had to change the variable (conts) to (let) because a value assigned to (conts) can not be assign again, while with (let) it can be reassigned diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..298ddd5fc 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,7 @@ // 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}`); + +//It is important to declare a variable before using it. \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..3cd00fd12 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,4 +1,4 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber @@ -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 + +console.log(last4Digits) + + +//The number attributed to the value cardNumber is not a String, so we need to make the make a string. \ No newline at end of file diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..0171169ba 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,7 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const formatAs12HourClockTime = "20:53"; +const formatAs24hourClockTime = "08:53"; + +console.log(formatAs12HourClockTime) +console.log(formatAs24hourClockTime) + +//Variable names do not start with numbers. \ No newline at end of file From 854e79eb9cb6a82e033a5d667f78551ffcf14663 Mon Sep 17 00:00:00 2001 From: FarancisGH Date: Sat, 7 Mar 2026 10:09:35 +0000 Subject: [PATCH 3/4] Regular changes and adjustments done on sprint-1 --- Sprint-1/2-mandatory-errors/1.js | 2 +- .../3-mandatory-interpret/1-percentage-change.js | 15 +++++++++++++-- Sprint-1/3-mandatory-interpret/2-time-format.js | 8 ++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 26a743d59..341ab8177 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -6,4 +6,4 @@ age = age + 1; console.log (age); -//I had to change the variable (conts) to (let) because a value assigned to (conts) can not be assign again, while with (let) it can be reassigned +//I had to change the variable (const) to (let) because a value assigned to (const) can not be assign again, while with (let) it can be reassigned diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..a7534fa89 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; @@ -11,12 +11,23 @@ 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 +// a) How many function calls are there in this file? Write down all the lines where a function call is made: +// 5 which are: 2 number(), 2 replaceAll() and 1 console.log() // 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 on line 5, there is a missing comma that needs to seperate the arguments of replaceAll().Will fix it by putting the comma. // c) Identify all the lines that are variable reassignment statements +// Line 4 and 5 // d) Identify all the lines that are variable declarations +// Line 1, 2, 7 and 8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// The purpose is to: + +// Remove formatting (commas) from a number string + +// Convert the cleaned string into a real number + +// Allow mathematical calculations to be performed diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..8fbe02f00 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,22 @@ 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? +// 6 variable declaration. Which are movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result // b) How many function calls are there? +// 1 functions, which is Console.log // c) Using documentation, explain what the expression movieLength % 60 represents +// It represents the remainder expression. This means that the remainder operator returns the remainder left over when one operand is divided by a second operand. +// // 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? +// This command calculate the number of hours in the expression then extract the leftover minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// It creates a formated string. for example: 2:30:23. That is the movie duration formated in Hours:Minutes:Seconds. +//Better names could be; FormatedDuration or MovieDuration or FormatedTime. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// It would Works for positive integers only; not ideal for negatives, decimals, or proper formatting. From bc447ba652c1e97758058b6406d3be9dea088b78 Mon Sep 17 00:00:00 2001 From: FarancisGH Date: Sat, 7 Mar 2026 13:56:49 +0000 Subject: [PATCH 4/4] Further adjustment done on Sprint-1 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 19 +++++++++++++++++++ 1 file changed, 19 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..2eda5754b 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,22 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +//For line 3 and 5 (const penceStringWithoutTrailingP = penceString.substring 0, penceString.length - 1)= substring(start, end) extracts part of a string. + +//0 means start at the beginning. + +//penceString.length - 1 means stop before the last character. + +//For "399p": + +//length = 4 + +//4 - 1 = 3 + +//substring from 0 to 3 → "399" + +// The purpose is to; + +//Removes the "p" at the end of the string. + +//Leaves only the numeric value "399"