From 9db28b253102b9773accadd9c3ec4cdd1d7943e0 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 22:17:40 +0000 Subject: [PATCH 01/12] Added notes to described what the code on line 3 is doing --- Sprint-1/1-key-exercises/1-count.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..6f3f87a78 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,6 +1,12 @@ let count = 0; count = count + 1; +console.log(count); // 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 value of the count variable to the result of the expression count + 1. +// The = operator is the assignment operator, which assigns the value on the right-hand side +// (the result of count + 1) to the variable on the left-hand side (count). +// This increments the value of count by 1. \ No newline at end of file From 683ae71ceab3c978738248c7a4284131a7b92b30 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 22:26:16 +0000 Subject: [PATCH 02/12] Declared variable initials to store 1st chars of strings --- 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 47561f617..110f850dc 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 fca74e94ab71582da7097e49001c2c3fe7ee42a1 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 22:57:49 +0000 Subject: [PATCH 03/12] assigned values to variables dir and ext (3-paths.js) Utilized prettier to format code in (1-count.js; 2-initials.js; 3-paths.js) --- Sprint-1/1-key-exercises/1-count.js | 6 +++--- Sprint-1/1-key-exercises/2-initials.js | 1 - Sprint-1/1-key-exercises/3-paths.js | 9 ++++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 6f3f87a78..4fdf1fdee 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -7,6 +7,6 @@ console.log(count); // Describe what line 3 is doing, in particular focus on what = is doing // Line 3 is reassigning the value of the count variable to the result of the expression count + 1. -// The = operator is the assignment operator, which assigns the value on the right-hand side -// (the result of count + 1) to the variable on the left-hand side (count). -// This increments the value of count by 1. \ No newline at end of file +// The = operator is the assignment operator, which assigns the value on the right-hand side +// (the result of count + 1) to the variable on the left-hand side (count). +// This increments the value of count by 1. diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 110f850dc..c0885c4c2 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -10,4 +10,3 @@ let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn - diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..3d7f1964d 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); +console.log(`the dir part of ${filePath} is ${dir}`); -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +const ext = filePath.slice(filePath.lastIndexOf(".")); +console.log(`the ext part of ${filePath} is ${ext}`); + +// https://www.google.com/search?q=slice+mdn From 906ab3422770cee56926173b44ffe7d1856104db Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 23:26:08 +0000 Subject: [PATCH 04/12] included notes to work out what num represents; by breaking down the expression --- Sprint-1/1-key-exercises/4-random.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..3d002403c 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -3,7 +3,32 @@ 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 // Try logging the value of num and running the program several times to build an idea of what the program is doing + +// when first evaluating the full num expression i got the answer 99 +// The second time i got 50 (which means .floor and .random are doing something to change the value of the expression each run) + +// The order of operations is as follows: + +// 1. The expression inside the parentheses is evaluated first: (maximum - minimum + 1) which gives us 100 - 1 + 1 = 100 +// 2. Then Math.random() is called, which generates a random decimal number between 0 and 1. +// 3. The result of Math.random() is multiplied by the result of step 1, giving us a random decimal number between 0 and 100. +// 4. Math.floor() is then called on the result of step 3, which rounds it down to the nearest whole number, giving us a random integer between 0 and 99. +// 5. Finally, the minimum value (1) is added to the result of step 4, giving us a random integer between 1 and 100. + +// When num = 99 +// math.random gives us 0.98 (or something close to it) +// 0.98 * 100 = 98 +// math.floor(98) = 98 +// 98 + 1 = 99 + +// When num = 50 +// math.random gives us 0.49 (or something close to it) +// 0.49 * 100 = 49 +// math.floor(49) = 49 +// 49 + 1 = 50 From a273daad0399a7f3d1c54451d1443d854f738cb6 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 23:28:28 +0000 Subject: [PATCH 05/12] converted instruction lines into comments --- 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 cf6c5039f..d1802c99a 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? + +//We solve the problem by commenting out the lines - +// this means that the computer will ignore them when it runs the program From c0c20fc962124ad6a6422062de2a6e7365b30e70 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 23:31:29 +0000 Subject: [PATCH 06/12] changed const to let to allow age variable to be reassigned --- Sprint-1/2-mandatory-errors/1.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..6ef2ea979 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,6 @@ // 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); From 934aeec568819dc01abdb6ce345dca2c3f9f548e Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 23:37:31 +0000 Subject: [PATCH 07/12] place cityOfBirth variable and assigned value ahead of console log statement to fix error --- Sprint-1/2-mandatory-errors/2.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..cb53dcf09 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,14 @@ // 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}`); + +//ReferenceError: Cannot access 'cityOfBirth' before initialization + +// This is happening because we are trying to use the variable cityOfBirth +// before it has been declared and assigned a value. + +// Variables declared with let and const can't be accessed before they are initialized. + +// To fix this error, we need to declare and assign a value to cityOfBirth before we try to log it to the console. From 2cd98a18a34b97a5bda263ba2ffcc4006c1fe8a7 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 23:43:25 +0000 Subject: [PATCH 08/12] converted cardNumber to string to achieve desired output and included comments --- Sprint-1/2-mandatory-errors/3.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..d3141b836 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,9 +1,19 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); +console.log(last4Digits); + // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working // Before running the code, make and explain a prediction about why the code won't work // 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 + +// initial prediction: +// I don't think the code will work because cardNumber is a number, and the slice method is a string method. + +// The error I get is: TypeError: cardNumber.slice is not a function + +// This error is happening because the slice method is being called on a number, +// which does not have the slice method. The slice method is only available for strings and arrays. From 846928b9c49b6f9343ccb2ed659eb7accf5c9dd7 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Tue, 17 Feb 2026 23:48:27 +0000 Subject: [PATCH 09/12] updated variable names to start with letters to fix syntax error --- 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 21dad8c5d..956a38c55 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 twelveHourClockTime = "20:53"; +const twentyFourHourClockTime = "08:53"; + +console.log(twelveHourClockTime, twentyFourHourClockTime); + +//SyntaxError: Invalid or unexpected token + +// This error is happening because variable names cannot start with a number. +// To fix this error, we can change the variable names to start with a letter instead of a numbers. From 0fad45ec8103df9cc06e902fe2c51ffbba73910d Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Wed, 18 Feb 2026 22:42:13 +0000 Subject: [PATCH 10/12] answered Qs with updates notes fixed syntax error to ensure code runs as expected --- .../1-percentage-change.js | 25 ++++++++++++++++++- 1 file changed, 24 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 e24ecb8e1..50e71375a 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; @@ -13,10 +13,33 @@ console.log(`The percentage change is ${percentageChange}`); // a) How many function calls are there in this file? Write down all the lines where a function call is made +// Function calls are determined by the presence of parentheses "()" after a function name. +// Therefore in this file, there are 6 function calls: + // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? +// The error is occurring on line 5: +// SyntaxError: missing ) after argument list. This is because there is a missing comma between the two arguments +// (search value & replace value) in the replaceAll function. +// To fix this problem, we can add a comma between the two arguments. + // c) Identify all the lines that are variable reassignment statements +// These lines include: +// line 3: let carPrice = "10,000"; to carPrice = Number(carPrice.replaceAll(",", "")); +// line 4: let priceAfterOneYear = "8,543"; to priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); + // d) Identify all the lines that are variable declarations +// These lines include: +// line 3: let carPrice = "10,000"; +// line 4: let priceAfterOneYear = "8,543"; +// line 6: const priceDifference = carPrice - priceAfterOneYear; +// line 7: const percentageChange = (priceDifference / carPrice) * 100; + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + +// The purpose of this is expression is to search for remove all commas from the string value of carPrice and replace them with an empty string. +// This converts the CarPrice value from a string to a type number, which we can now perform mathematical operations on. +// Since the purpose of this program is to calculate the percentage change in the price of a car. +// We need type number values to perform the necessary calculations. From 976fb67eaae07325e20315c9aa2a5ee6b169df3e Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Wed, 18 Feb 2026 23:59:35 +0000 Subject: [PATCH 11/12] updated notes to answer question --- .../3-mandatory-interpret/2-time-format.js | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..72c785de3 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = true; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -13,13 +13,48 @@ console.log(result); // a) How many variable declarations are there in this program? +// There are 6 variable declarations in this program. + // b) How many function calls are there? +// There is 1 function call in this program. + // 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? +// The expression movieLength % 60 is using the modulus operator (%) to calculate the remainder when movieLength is divided by 60. +// In this context, it is calculating the number of seconds that are left over after accounting for the full minutes in the movie length. + +// d) Interpret line 4, what does the expression assigned to totalMinutes mean + +// It calculates the total number of minutes in the movie by first subtracting the remaining seconds from the total movie length (in seconds) +// and then dividing the result by 60 (the number of seconds in a minute). This gives us the total number of full minutes in the movie length. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// The variable result has the value of a template literal that combines the total hours, remaining minutes, and remaining seconds +// into a string format that represents the length of the movie in hours, minutes, and seconds separated by colons. +// A better name for this variable could be "formattedMovieLength" +// to more clearly indicate that it represents the movie length formatted as hours, minutes, and seconds. + // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + +// Test 1: movieLength = 1 +// Expected output: 0:0:1 +// Actual output: 0:0:1 + +// Test 2: movieLength = -1 +// Expected output: 0:0:-1 +// Actual output: 0:0:-1 + +// Test 3: movieLength = "3,600" +// Expected output: type error +// Actual output: NaN:NaN:NaN + +// Test 4: movieLength = true +// Expected output: 0:0:1 +// Actual output: 0:0:1 + +// The code will work for all values of movieLength that are of type number or can be coerced to a number (like true which is coerced to 1). +// This is because arithmetic operation need to be performed on movieLength, and if it is not a number or cannot be coerced to a number, +// It will result in NaN (Not a Number) for the calculations of totalMinutes, remainingMinutes, totalHours, and ultimately the result variable. From af476362c2e1a3300da503d4aec98e7083af8bd0 Mon Sep 17 00:00:00 2001 From: Ales-Os-Dev_Lab Date: Sat, 21 Feb 2026 09:42:02 +0000 Subject: [PATCH 12/12] updated penceString file and expanded comments to include breakdown and rationale of the program --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..c2f4a1087 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,4 +1,4 @@ -const penceString = "399p"; +const penceString = "9p"; const penceStringWithoutTrailingP = penceString.substring( 0, @@ -25,3 +25,98 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" + +// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1) : intialises a variable +// with the value of the penceString variable with the last character "p" removed. + +// a. This is achieved by using the substring method on the penceString variable +// the substring method enables the program to manipulate the penceSting variable by targeting and removing characters in the string. + +// b. The first argument of the substring method indicates the starting index; (0) which is 399p[0] = "3" + +// c. The second argument of the substring method indicates the ending index (penceString.length - 1) +// (.length) returns the length of the string object which is 4, and (-1) targets the last character in the string which is "p". +// +// d. Therefore, the substring method will return a new string that starts from index 0 and ends at index 3 which is "399" + +// e. If const penceString = "1399p" the penceStringWithoutTrailingP variable will have the value "1399" +// because the substring method will indicate the starting index as (0 which = "1") +// and the ending index as (penceString.length - 1) which is 5 - 1 = 4, which is "p" +// therefore it will return a new string that starts from index 0 and ends at index 4 which is "1399" + +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0") : initialises a variable +// with the value of the penceStringWithoutTrailingP variable with padding added to the start of the string +// until it reaches a total length of 3 characters. + +// a. This is achieved by using the padStart method on the penceStringWithoutTrailingP variable +// the padStart method enables the program to manipulate the penceStringWithoutTrailingP variable +// by adding padding to the start of the string until it reaches a specified length. + +// b. The first argument of the padStart method indicates the target length of the resulting string which is 3 in this case. + +// c. The second argument of the padStart method indicates the string to use to fill or pad which is "0" in this case. +// +// d. Therefore, if the penceStringWithoutTrailingP variable has a length of less than 3 characters, +// the padStart method will add "0" characters to the start of the string until it reaches a total length of 3 characters. +// In this case, since penceStringWithoutTrailingP is "399" which already has a length of 3 characters, +// the padStart method will not add any padding and paddedPenceNumberString will also be "399". + +// e. if const penceStringWithoutTrailingP = "99" the paddedPenceNumberString variable will have the value "099" +// because the padStart method will add one "0" character to the start of the string until it reaches a total length of 3 characters. + +// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2) : initialises a variable +// with the value of the paddedPenceNumberString variable with the last two characters removed. + +// a. This is achieved by using the substring method on the paddedPenceNumberString variable +// the substring method enables the program to manipulate the paddedPenceNumberString variable by targeting and removing characters in the string. + +// b. The first argument of the substring method indicates the starting index; (0) which is 399[0] = "3" + +// c. The second argument of the substring method indicates the ending index (paddedPenceNumberString.length - 2) +// (.length) returns the length of the string object which is 3, and (-2) targets the last two characters in the string which is "99" +// +// d. Therefore it will return a new string that starts from index 0 and ends at index 1 which is "3" + +// d. If const paddedPenceNumberString = "099" the pounds variable will have the value "0" because the substring method +// will indicate the starting index as (0 which = "0") and the ending index as (paddedPenceNumberString.length - 2) +// which is 3 - 2 = 1, which is "9" therefore it will return a new string that starts from index 0 and ends at index 0 which is "0" + +// e. if penceString = "1399p" ; const penceStringWithoutTrailingP = "1399" ; const paddedPenceNumberString = "1399" +// because the padStart method will not add any padding since the length of penceStringWithoutTrailingP is already 4 characters +// which is greater than the target length of 3 characters. therefore the const pounds variable will have the value "13" +// because the substring method will indicate the starting index as (0 which = "1") and the ending index as +// (paddedPenceNumberString.length - 2) which is 4 - 2 = 2, which is "9" therefore it will return a new string that starts from index 0 +// and ends at index 1 which is "13" + +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0") : initialises a variable +// with the value of the last two characters of the paddedPenceNumberString variable with padding added to the end of the string +// until it reaches a total length of 2 characters. + +// a. This is achieved by using the substring method on the paddedPenceNumberString variable to extract the last two characters of the string, +// and then using the padEnd method to add padding to the end of the string until it reaches a specified length. + +// b. The first argument of the substring method indicates the starting index which is (paddedPenceNumberString.length - 2) +// which targets the last two characters in the string. The ending index is not provided, so it will extract until the end of the string. +// + +// c. The padEnd method is then used on the resulting string from the substring method to add padding to the end of the string +// until it reaches a total length of 2 characters. + +// d. The first argument of the padEnd method indicates the target length of the resulting string which is 2 in this case. + +// e. The second argument of the padEnd method indicates the string to use to fill or pad which is "0" in this case. + +// f. Therefore, if the paddedPenceNumberString variable has a length of less than 2 characters, the padEnd method will add "0" characters +// to the end of the string until it reaches a total length of 2 characters. +// In this case, since paddedPenceNumberString is "399" which has a length of 3 characters, +// the substring method will extract the last two characters "99" +// and then the padEnd method will not add any padding since the length of the resulting string is already 2 characters. +// therefore pence will be "99" + +// g. if penceString = "9p" ; const penceStringWithoutTrailingP = "9" ; const paddedPenceNumberString = "009" ; +// const pounds = "0" ; const pence = "09" because the substring method will extract the last two characters "09" +// and then the padEnd method will not add any padding since the length of the resulting string is already 2 characters. +// therefore pence will be "09" + +// 6. console.log(`£${pounds}.${pence}`) : outputs the final result to the console in the format of "£pounds.pence" +// where pounds and pence are the values of the pounds and pence variables respectively.