From c77a685a63dfe26a1ba714f91e278ce761735582 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 17:22:03 +0100 Subject: [PATCH 01/31] Update 1-count.js Detailed answer to questions --- Sprint-1/1-key-exercises/1-count.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..4e293f2f6 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -3,4 +3,10 @@ let count = 0; 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 +// Describe what line 3 is doing, in particular, focus on what = is doing + + +//The answers: +//In line 1, the declared value is set to 0. In line 3, the value is redefined and set to count + 1. So the initial count value was 0, and the new value is 0 + 1. +//In programming terms, the value of count increments by 1. +//The equal sign is an assignment operation. It assigns the value on the right side of the = to the variable on the left side. From 78adab76b21d98d287f980b9de5031d09419e056 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 18:02:52 +0100 Subject: [PATCH 02/31] Update 2-initials.js --- 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 47561f617..0238a71c6 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 = ``; +let initials = firstName[0] + middleName[0] + lastName[0]; // https://www.google.com/search?q=get+first+character+of+string+mdn From d3dc329fa540d7500a3518dd1923c498c14606fb Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 18:42:22 +0100 Subject: [PATCH 03/31] Update 3-paths.js --- Sprint-1/1-key-exercises/3-paths.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..d45da5962 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,7 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable -const dir = ; -const ext = ; +const dir = filePath.slice(0, lastSlashIndex); +const ext = base.slice(base.lastIndexOf(".") + 1); -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +// https://www.google.com/search?q=slice+mdn From 6e519a662b5121b4fb9ee2364448c3974d49644b Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 18:47:35 +0100 Subject: [PATCH 04/31] Update 2-initials.js --- Sprint-1/1-key-exercises/2-initials.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 0238a71c6..737e39bd7 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -6,6 +6,7 @@ let lastName = "Johnson"; // 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]; +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From bc851935d2ff4efa1e57fe7cb03c7d8b5f8bd845 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 18:52:42 +0100 Subject: [PATCH 05/31] Update 3-paths.js --- Sprint-1/1-key-exercises/3-paths.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index d45da5962..2aa8fe491 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -18,6 +18,9 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the ext part of the variable const dir = filePath.slice(0, lastSlashIndex); +console.log(`The dir part of ${filePath} is: ${dir}`); + const ext = base.slice(base.lastIndexOf(".") + 1); +console.log(`The ext part of ${filePath} is: ${ext}`); // https://www.google.com/search?q=slice+mdn From a7002a744bd808d1dd6263dbeb9ed5e913e36247 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 19:55:11 +0100 Subject: [PATCH 06/31] Update 4-random.js --- Sprint-1/1-key-exercises/4-random.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..61f6973e9 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,27 @@ 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 is a variable that returns a random number between 1 and 100, inclusive. + +// - Math.floor(); rounds down a number to its nearest integer. +// - Math.random(); it returns an unexpected value within the specified range. Usually it is between 0 and 1, but excluding 1. +// - (maximum - minimum + 1); This formula represents the range. Maximum means the maximum number minus the minimum number + 1. +// - minimum; this is the minimum number added to the formula to generate a number within the range. + +// The formula works as follows: + +// • We use the formula (maximum - minimum + 1) to calculate the size of the desired range. +// In the example above, maximum = 100 and minimum = 1. +// So: 100 - 1 = 99, then 99 + 1 = 100. +// • Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). +// For example: 0.0001, 0.5342, 0.9999. +// • We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. +// Example: 0.9999 * 100 = 99.99. +// • We then use Math.floor() to round the result down to the nearest whole number. +// Example: Math.floor(99.99) = 99. +// • Finally, we add the minimum value to shift the result into the correct range. +// Example: 99 + 1 = 100. From 7ef1d3bd23ce3df193ed138a6fe62d09b5569c91 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:00:01 +0100 Subject: [PATCH 07/31] Update 4-random.js --- Sprint-1/1-key-exercises/4-random.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 61f6973e9..83e07dfcc 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -20,14 +20,14 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // The formula works as follows: -// • We use the formula (maximum - minimum + 1) to calculate the size of the desired range. +// •We use the formula (maximum - minimum + 1) to calculate the size of the desired range. // In the example above, maximum = 100 and minimum = 1. // So: 100 - 1 = 99, then 99 + 1 = 100. -// • Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). +// •Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). // For example: 0.0001, 0.5342, 0.9999. -// • We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. +// •We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. // Example: 0.9999 * 100 = 99.99. -// • We then use Math.floor() to round the result down to the nearest whole number. +// •We then use Math.floor() to round the result down to the nearest whole number. // Example: Math.floor(99.99) = 99. -// • Finally, we add the minimum value to shift the result into the correct range. +// •Finally, we add the minimum value to shift the result into the correct range. // Example: 99 + 1 = 100. From 899fccb07eca7cabf2322b2adc094616007de7cb Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:00:55 +0100 Subject: [PATCH 08/31] Update 4-random.js --- Sprint-1/1-key-exercises/4-random.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 83e07dfcc..df53d7c5a 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -20,14 +20,14 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // The formula works as follows: -// •We use the formula (maximum - minimum + 1) to calculate the size of the desired range. +// •We use the formula (maximum - minimum + 1) to calculate the size of the desired range. // In the example above, maximum = 100 and minimum = 1. // So: 100 - 1 = 99, then 99 + 1 = 100. -// •Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). +// •Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). // For example: 0.0001, 0.5342, 0.9999. -// •We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. +// •We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. // Example: 0.9999 * 100 = 99.99. -// •We then use Math.floor() to round the result down to the nearest whole number. +// •We then use Math.floor() to round the result down to the nearest whole number. // Example: Math.floor(99.99) = 99. -// •Finally, we add the minimum value to shift the result into the correct range. +// •Finally, we add the minimum value to shift the result into the correct range. // Example: 99 + 1 = 100. From 6d9a7e11d61539537863294f8497a1b187b1b114 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:02:12 +0100 Subject: [PATCH 09/31] Update 4-random.js --- Sprint-1/1-key-exercises/4-random.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index df53d7c5a..eaabb6882 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -20,14 +20,14 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // The formula works as follows: -// •We use the formula (maximum - minimum + 1) to calculate the size of the desired range. +// - We use the formula (maximum - minimum + 1) to calculate the size of the desired range. // In the example above, maximum = 100 and minimum = 1. // So: 100 - 1 = 99, then 99 + 1 = 100. -// •Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). +// - Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). // For example: 0.0001, 0.5342, 0.9999. -// •We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. +// - We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. // Example: 0.9999 * 100 = 99.99. -// •We then use Math.floor() to round the result down to the nearest whole number. +// - We then use Math.floor() to round the result down to the nearest whole number. // Example: Math.floor(99.99) = 99. -// •Finally, we add the minimum value to shift the result into the correct range. +// - Finally, we add the minimum value to shift the result into the correct range. // Example: 99 + 1 = 100. From 1feed182ca76c3ffa242226b8b3588a3784abe45 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:04:12 +0100 Subject: [PATCH 10/31] Update 1.js --- Sprint-1/2-mandatory-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..031839b47 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,4 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; age = age + 1; From 522c3611e8d2014daff3f4a39aed3cb8a81e7219 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:04:53 +0100 Subject: [PATCH 11/31] Update 1.js --- Sprint-1/2-mandatory-errors/1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 031839b47..6ef2ea979 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,3 +2,5 @@ let age = 33; age = age + 1; + +console.log(age); From 093b6ede053f54221232d1cbbe683f6ae260faf8 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:07:26 +0100 Subject: [PATCH 12/31] Update 2.js --- 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 e09b89831..2865eb8a4 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,5 @@ // 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}`); From aa257246de91170bc65e289a682115ece887a616 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:34:03 +0100 Subject: [PATCH 13/31] Update 3.js --- Sprint-1/2-mandatory-errors/3.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..c0b69a12c 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -7,3 +7,16 @@ 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 + + + +// Answers: + +/// The code isn't working because the variable `cardNumber` is just a number, not a string or an array. +// The `slice` method only works on strings or arrays. +// So if we call `const last4Digits = cardNumber.slice(-4);`, it gives an error because `.slice` is not a function for numbers. +// Yes, I predicted the error because the variable `cardNumber` is not assigned a string. + +const last4Digits = cardNumber.toString().slice(-4); + +console.log(last4Digits); From 61c564746fd432465ad1a080922695182e62a69b Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 20:45:59 +0100 Subject: [PATCH 14/31] Update 4.js --- Sprint-1/2-mandatory-errors/4.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..8a5dda1ab 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,8 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const hour24ClockTime = "20:53"; +console.log(hour24ClockTime); + +const hour12ClockTime = "08:53"; +console.log(hour12ClockTime); + +// The variables were renamed because JavaScript does not allow variables to start with numbers +// camelCase format used for variable names From d7503e7b43277447a3c784ab32cb188b2f2eafef Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Tue, 10 Jun 2025 21:58:19 +0100 Subject: [PATCH 15/31] Update 1-percentage-change.js --- .../1-percentage-change.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..33ad607a0 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -13,10 +13,40 @@ 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 + // There are 5 function calls + + // Line 4 - carPrice = Number(carPrice.replaceAll(",", "")); + // carPrice.replaceAll() + // Number() + + // Line 5 - priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); + // priceAfterOneYear.replaceAll() + // NUmber() + + // Line 10 - + // 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? + // There is a syntax error; a comma is missing in line 5. There are two strings stuck together without a separator, so the comma will separate the two arguments. + // c) Identify all the lines that are variable reassignment statements + // Line 4 - carPrice + // Line 5 - priceAfterOneYear + // d) Identify all the lines that are variable declarations + // Line 1 - let (let carPrice = "10,000";) + // Line 2 - let (let priceAfterOneYear = "8,543";) + // Line 7 - const (const priceDifference = carPrice - priceAfterOneYear;) + // Line 8 - const (const percentageChange = (priceDifference / carPrice) * 100;) + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + + // When the function is called, the value is stored as a string with commas. For example, the car price will be "10,000" (with a comma). + // JavaScript does not recognise a number with a comma in it, so it cannot perform numeric operations on such strings. + // The .replaceAll(",", "") function removes all commas (",") and replaces them with nothing (""), effectively deleting them. + // So "1,000" becomes "1000", a string without commas. + // The outer Number() function then converts the string "1000" into the number 1000, so it can be used in mathematical calculations. From c69cb255c563f96bda79cdbc7331471a6f923e13 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 18:17:53 +0100 Subject: [PATCH 16/31] Update 2-time-format.js --- .../3-mandatory-interpret/2-time-format.js | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..95249c13c 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -11,15 +11,105 @@ 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? + // There are six variable declarations in the code: + + // Line 1 – const movieLength: + // Stores the total duration of the movie in seconds. + + // Line 3 – const remainingSeconds: + // Calculates the number of seconds remaining after converting to full minutes. + + // Line 4 – const totalMinutes: + // Stores the total number of full minutes, excluding the leftover seconds. + + // Line 6 – const remainingMinutes: + // Calculates the remaining minutes after converting to full hours. + + // Line 7 – const totalHours: + // Stores the total number of full hours in the movie duration. + + // Line 9 – const result: + // Constructs the final time in "HH:MM:SS" format as a string. + +//----------------------------------------------------------------------------------------------- // b) How many function calls are there? + // There is one function call in the code: + + // console.log(result): + // This function outputs the final formatted time (in "HH:MM:SS" format) to the console. + +//----------------------------------------------------------------------------------------------- // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators + // The expression "movieLength % 60" uses the modulo operator, + // which is an arithmetic operation that returns the remainder + // after division. + + // In this context, it helps determine how many seconds are left + // after converting the total movie length into full minutes. + + // For example: + // movieLength = 8784 seconds + // 8784 ÷ 60 = 146 full minutes with a remainder of 24 seconds + // So, movieLength % 60 = 24 + + // These 24 seconds are what remain after dividing the movie length + // into whole minutes. + + // If we subtract the 24 seconds from the total: + // 8784 - 24 = 8760 seconds + // Then: 8760 ÷ 60 = 146 full minutes + +//----------------------------------------------------------------------------------------------- // d) Interpret line 4, what does the expression assigned to totalMinutes mean? + // (movieLength - remainingSeconds): + // This subtracts the "remainingSeconds" (24) from the total "movieLength" (8784 seconds). + // The purpose is to remove the leftover seconds, leaving only the number of seconds + // that make up complete minutes. + + // / 60: + // This divides the result by 60 (since there are 60 seconds in a minute) + // to convert the remaining seconds into full minutes. + + // totalMinutes: + // This represents the total number of whole minutes in the movie, + // which in this example is 146. + +//----------------------------------------------------------------------------------------------- // e) What do you think the variable result represents? Can you think of a better name for this variable? + // The variable `const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;` + // represents the length of the movie formatted as hours:minutes:seconds (HH:MM:SS). + + // A more descriptive name for this variable could be "movieDurationTime", + // as it clearly indicates that the value represents the movie's duration + // in a time format. + +//----------------------------------------------------------------------------------------------- // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + + // This code will not display properly for movies with a duration of 0 seconds, + // as the output would appear as "0:0:0", which is not well-formatted. + + // We can fix this by applying the .padStart() method to each time unit + // (hours, minutes, and seconds) to ensure they are always displayed + // with two digits — for example, "00:00:00". + + // We use .padStart() on string values because all the time units + // are integers, and this method works on strings. + + + + + + + + + + From 52a24eb61c908f3f0f9279dd8f649ee82f185e4f Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 19:31:14 +0100 Subject: [PATCH 17/31] Update 3-to-pounds.js --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 28 +++++++++++++++++++ 1 file changed, 28 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..fd2ec75a9 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,31 @@ 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); +// This line removes the last character from the input string, which is the letter "p" (representing pence). +// The reason we remove "p" is that we can't perform calculations on a string that includes non-numeric characters. + + +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +// This line ensures the string is at least three characters long by padding it with leading zeros if necessary. +// This formatting allows us to easily separate the value into pounds and pence — where the last two digits represent pence and the remaining digits represent pounds. + + +// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); +// This line extracts the pound portion of the value by taking all characters except the last two. +// For example, if the input is "399p", it becomes "399", and this line extracts "3" as the pound value. + + +// 5. const pence = paddedPenceNumberString +// .substring(paddedPenceNumberString.length - 2) +// .padEnd(2, "0"); +// This line extracts the last two digits, which represent the pence. +// The `.padEnd(2, "0")` ensures that even if the pence value is only one digit (e.g., "5"), it becomes two digits (e.g., "05"). +// So "5p" would correctly display as "£0.05" instead of "£0.5". + + +// 6. console.log(`£${pounds}.${pence}`); +// This line prints the final result in the correct British currency format. +// If the input is "399p", the output will be "£3.99". +// This step is important for presenting the value in a user-friendly and readable format. From 4189cd9af30da25a20f747cdc8eeab3dfc2f56c9 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:05:39 +0100 Subject: [PATCH 18/31] Update chrome.md --- Sprint-1/4-stretch-explore/chrome.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..4247dfba9 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -16,3 +16,26 @@ 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`? + + +What I Did in the Chrome Console + 1. I opened a new page in Google Chrome. + 2. I right-clicked on the page and selected Inspect. + 3. In the Developer Tools window, I clicked on the Console tab. + 4. I typed the function alert("Hello world!"); and pressed Enter. + 5. A pop-up appeared displaying the message “Hello world!”. I clicked OK to close it. + 6. Next, I typed const myName = prompt("What is your name?"); and pressed Enter. + 7. A dialogue box appeared with the message “What is your name?” and a text input field. + 8. I entered my name, Sed, into the input box and clicked OK. + 9. The browser stored my input in the variable myName. + 10. Then, I typed console.log("You entered:", myName); and pressed Enter. + 11. The console displayed: You entered: Sed + +What effect does calling the `prompt` function have? + It displays a dialog box that prompts the user to enter information. + If the result is assigned (e.g., const myName = prompt("What is your name?")), + the user’s input is stored in the variable (in this case, myName). + +What is the return value of `prompt`? + The value entered by the user is returned as a string. + If the user clicks Cancel, the return value is null. From bb7ddf7313d5d00ba82f57ec6a7b6cbe0beccdef Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:13:13 +0100 Subject: [PATCH 19/31] Update chrome.md --- Sprint-1/4-stretch-explore/chrome.md | 45 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index 4247dfba9..86cc2bf2d 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -18,24 +18,31 @@ What effect does calling the `prompt` function have? What is the return value of `prompt`? -What I Did in the Chrome Console - 1. I opened a new page in Google Chrome. - 2. I right-clicked on the page and selected Inspect. - 3. In the Developer Tools window, I clicked on the Console tab. - 4. I typed the function alert("Hello world!"); and pressed Enter. - 5. A pop-up appeared displaying the message “Hello world!”. I clicked OK to close it. - 6. Next, I typed const myName = prompt("What is your name?"); and pressed Enter. - 7. A dialogue box appeared with the message “What is your name?” and a text input field. - 8. I entered my name, Sed, into the input box and clicked OK. - 9. The browser stored my input in the variable myName. - 10. Then, I typed console.log("You entered:", myName); and pressed Enter. - 11. The console displayed: You entered: Sed +## What I Did in the Chrome Console -What effect does calling the `prompt` function have? - It displays a dialog box that prompts the user to enter information. - If the result is assigned (e.g., const myName = prompt("What is your name?")), - the user’s input is stored in the variable (in this case, myName). +1. I opened a new page in Google Chrome. +2. I right-clicked on the page and selected **Inspect**. +3. In the Developer Tools window, I clicked on the **Console** tab. +4. I typed the function `alert("Hello world!");` and pressed **Enter**. +5. A pop-up appeared displaying the message **"Hello world!"**. I clicked **OK** to close it. +6. Next, I typed `const myName = prompt("What is your name?");` and pressed **Enter**. +7. A dialog box appeared with the message **"What is your name?"** and a text input field. +8. I entered my name, **Sed**, into the input box and clicked **OK**. +9. The browser stored my input in the variable `myName`. +10. Then, I typed `console.log("You entered:", myName);` and pressed **Enter**. +11. The console displayed: `You entered: Sed` -What is the return value of `prompt`? - The value entered by the user is returned as a string. - If the user clicks Cancel, the return value is null. +--- + +## What Effect Does Calling the `prompt()` Function Have? + +It displays a dialog box that prompts the user to enter information. +If the result is assigned (e.g., `const myName = prompt("What is your name?");`), +the user's input is stored in the variable (in this case, `myName`). + +--- + +## What Is the Return Value of `prompt()`? + +The value entered by the user is returned as a **string**. +If the user clicks **Cancel**, the return value is **`null`**. From fbd05412bdba6f593c0aef96d955216a83bbdad3 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:35:59 +0100 Subject: [PATCH 20/31] Update objects.md --- Sprint-1/4-stretch-explore/objects.md | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..8f877d56d 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -14,3 +14,42 @@ Answer the following questions: What does `console` store? What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? + +Answers: + +# Exploring the Chrome DevTools Console + +**Open the Chrome DevTools Console, type `console.log` and then hit Enter** +Done. + +**What output do you get?** +I got: +ƒ log() { [native code] } + +**Now enter just `console` in the Console, what output do you get back?** +I got: +console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} + +**Try also entering `typeof console`** +I got: +“object” + +--- + +## What does `console` store? + +`console` is a JavaScript object that provides access to the browser's debugging console. +It stores functions such as `log`, `error`, `warn`, etc., which are used to track or print information while the code runs. + +--- + +## What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? + +It means to access the `log` function that belongs to the `console` object. + +--- + +## What does the `.` mean? + +The dot (`.`) is a notation in JavaScript used to access a property or function on an object. +So, `console.log()` means: call the `log` method that belongs to the `console` object. From 2fcc88ecdfcb24b3627c6586cf3f605c28dc596e Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:39:36 +0100 Subject: [PATCH 21/31] Update 1-count.js --- Sprint-1/1-key-exercises/1-count.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 4e293f2f6..503e5ae63 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -7,6 +7,9 @@ count = count + 1; //The answers: -//In line 1, the declared value is set to 0. In line 3, the value is redefined and set to count + 1. So the initial count value was 0, and the new value is 0 + 1. -//In programming terms, the value of count increments by 1. -//The equal sign is an assignment operation. It assigns the value on the right side of the = to the variable on the left side. +// In line 1, the variable `count` is declared and initialised with the value `0`. +// In line 3, the value of `count` is updated by assigning it the result of `count + 1`. Since the initial value was `0`, the new value becomes `0 + 1`, which is `1`. + +// In programming terms, this means the variable `count` is incremented by `1`. + +// The equals sign (`=`) is the assignment operator. It assigns the value on the right side of the `=` to the variable on the left side. From 26f8858acf1f12e83c925616836762212f3369d7 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:43:30 +0100 Subject: [PATCH 22/31] Update 4-random.js --- Sprint-1/1-key-exercises/4-random.js | 34 ++++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index eaabb6882..a8621a405 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -11,23 +11,17 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Answers: -// num is a variable that returns a random number between 1 and 100, inclusive. - -// - Math.floor(); rounds down a number to its nearest integer. -// - Math.random(); it returns an unexpected value within the specified range. Usually it is between 0 and 1, but excluding 1. -// - (maximum - minimum + 1); This formula represents the range. Maximum means the maximum number minus the minimum number + 1. -// - minimum; this is the minimum number added to the formula to generate a number within the range. - -// The formula works as follows: - -// - We use the formula (maximum - minimum + 1) to calculate the size of the desired range. -// In the example above, maximum = 100 and minimum = 1. -// So: 100 - 1 = 99, then 99 + 1 = 100. -// - Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). -// For example: 0.0001, 0.5342, 0.9999. -// - We multiply the result of Math.random() by (maximum - minimum + 1) to scale it to the desired range. -// Example: 0.9999 * 100 = 99.99. -// - We then use Math.floor() to round the result down to the nearest whole number. -// Example: Math.floor(99.99) = 99. -// - Finally, we add the minimum value to shift the result into the correct range. -// Example: 99 + 1 = 100. +// num is a variable that stores a random integer between 1 and 100, inclusive. +// • Math.floor() rounds a number down to the nearest integer. +// • Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). +// • (maximum - minimum + 1) calculates the size of the range of possible numbers. Here, it is 100 - 1 + 1 = 100. +// • minimum is added at the end to shift the result so that it falls within the desired range starting from the minimum value. + +// How the formula works: +// 1. Calculate the size of the range using (maximum - minimum + 1). In this example, with maximum = 100 and minimum = 1, the range size is 100 - 1 + 1 = 100. +// 2. Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive), such as 0.0001 or 0.9999. +// 3. Multiply the result of Math.random() by the range size to scale the number. For example: 0.9999 * 100 = 99.99. +// 4. Use Math.floor() to round the scaled number down to the nearest whole number. For example: Math.floor(99.99) = 99. +// 5. Add the minimum value to shift the number into the correct range. For example: 99 + 1 = 100. + +// This ensures that num will always be an integer between 1 and 100, inclusive. From 5c3b903f70b8e8e611942a2f804650da749e474e Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:45:52 +0100 Subject: [PATCH 23/31] Update 3.js --- Sprint-1/2-mandatory-errors/3.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index c0b69a12c..732710fdf 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -12,10 +12,11 @@ const last4Digits = cardNumber.slice(-4); // Answers: -/// The code isn't working because the variable `cardNumber` is just a number, not a string or an array. -// The `slice` method only works on strings or arrays. -// So if we call `const last4Digits = cardNumber.slice(-4);`, it gives an error because `.slice` is not a function for numbers. -// Yes, I predicted the error because the variable `cardNumber` is not assigned a string. +// The code isn’t working because the variable cardNumber is a number, not a string or an array. +// The slice method only works on strings or arrays. +// Therefore, calling const last4Digits = cardNumber.slice(-4); causes an error because .slice is not a function available for numbers. + +// I predicted this error because the variable cardNumber was not assigned as a string. const last4Digits = cardNumber.toString().slice(-4); From 209fa445a3fa8648a6bce6191bb39f9e658dfd9a Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:54:05 +0100 Subject: [PATCH 24/31] Update 1-percentage-change.js --- .../1-percentage-change.js | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 33ad607a0..c8cfba2a2 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -13,28 +13,34 @@ 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 - // There are 5 function calls +// There are 5 function calls: - // Line 4 - carPrice = Number(carPrice.replaceAll(",", "")); - // carPrice.replaceAll() - // Number() +// • Line 4 — carPrice = Number(carPrice.replaceAll(",", "")); +// • carPrice.replaceAll() +// • Number() - // Line 5 - priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); - // priceAfterOneYear.replaceAll() - // NUmber() +// • Line 5 — priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +// • priceAfterOneYear.replaceAll() +// • Number() - // Line 10 - - // console.log() +// • Line 10 — 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? - // There is a syntax error; a comma is missing in line 5. There are two strings stuck together without a separator, so the comma will separate the two arguments. +// There is a syntax error on line 5. +// The two strings inside the replaceAll method are missing a comma separator, causing them to be concatenated incorrectly. +// Adding the missing comma between the two arguments will fix the problem. + +//⸻ // c) Identify all the lines that are variable reassignment statements - // Line 4 - carPrice - // Line 5 - priceAfterOneYear +// • Line 4 — reassignment of carPrice +// • Line 5 — reassignment of priceAfterOneYear + +//⸻ // d) Identify all the lines that are variable declarations @@ -45,8 +51,7 @@ console.log(`The percentage change is ${percentageChange}`); // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? - // When the function is called, the value is stored as a string with commas. For example, the car price will be "10,000" (with a comma). - // JavaScript does not recognise a number with a comma in it, so it cannot perform numeric operations on such strings. - // The .replaceAll(",", "") function removes all commas (",") and replaces them with nothing (""), effectively deleting them. - // So "1,000" becomes "1000", a string without commas. - // The outer Number() function then converts the string "1000" into the number 1000, so it can be used in mathematical calculations. +// The value of carPrice is initially a string that includes commas, for example "10,000". +// JavaScript cannot perform numerical calculations on strings containing commas, as it does not recognise them as valid numbers. +// The method .replaceAll(",", "") removes all commas from the string, turning "10,000" into "10000". +// Finally, the Number() function converts the resulting string "10000" into the numeric value 10000, which allows mathematical operations to be performed on it. From 41f73ebea88bc90e007b95cc11c0c0615b0eddae Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:54:54 +0100 Subject: [PATCH 25/31] Update 1-percentage-change.js --- 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 c8cfba2a2..862a9adff 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -11,6 +11,8 @@ 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 function calls: @@ -49,6 +51,8 @@ console.log(`The percentage change is ${percentageChange}`); // Line 7 - const (const priceDifference = carPrice - priceAfterOneYear;) // Line 8 - const (const percentageChange = (priceDifference / carPrice) * 100;) +//⸻ + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? // The value of carPrice is initially a string that includes commas, for example "10,000". From ba814d57fc541a8770636a89193d4232ffcd6a73 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:55:27 +0100 Subject: [PATCH 26/31] Update 1-percentage-change.js --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 862a9adff..bd02cbc34 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -39,8 +39,8 @@ console.log(`The percentage change is ${percentageChange}`); // c) Identify all the lines that are variable reassignment statements -// • Line 4 — reassignment of carPrice -// • Line 5 — reassignment of priceAfterOneYear +// • Line 4 — reassignment of carPrice +// • Line 5 — reassignment of priceAfterOneYear //⸻ From 9363e1e9b556d31186068b65f1d3a6514b7aafdf Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 20:56:28 +0100 Subject: [PATCH 27/31] Update 1-percentage-change.js --- .../3-mandatory-interpret/1-percentage-change.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index bd02cbc34..cf353dbd9 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -11,7 +11,7 @@ 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 @@ -27,22 +27,21 @@ console.log(`The percentage change is ${percentageChange}`); // • Line 10 — 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? // There is a syntax error on line 5. // The two strings inside the replaceAll method are missing a comma separator, causing them to be concatenated incorrectly. // Adding the missing comma between the two arguments will fix the problem. -//⸻ +//----------------------------------------------------------------------------------------------- // c) Identify all the lines that are variable reassignment statements // • Line 4 — reassignment of carPrice // • Line 5 — reassignment of priceAfterOneYear -//⸻ +//----------------------------------------------------------------------------------------------- // d) Identify all the lines that are variable declarations @@ -51,8 +50,7 @@ console.log(`The percentage change is ${percentageChange}`); // Line 7 - const (const priceDifference = carPrice - priceAfterOneYear;) // Line 8 - const (const percentageChange = (priceDifference / carPrice) * 100;) -//⸻ - +//----------------------------------------------------------------------------------------------- // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? // The value of carPrice is initially a string that includes commas, for example "10,000". From 90e75d75d543397b7493375f780f515e2ff12740 Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 21:12:20 +0100 Subject: [PATCH 28/31] Update Sprint-1/4-stretch-explore/objects.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Sprint-1/4-stretch-explore/objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 8f877d56d..8e9a794ac 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -32,7 +32,7 @@ console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} **Try also entering `typeof console`** I got: -“object” +"object" --- From 374b28dd65328fa38c1f0455ec596c2c444cd9ad Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 23:11:28 +0100 Subject: [PATCH 29/31] Update 0.js --- Sprint-2/1-key-errors/0.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..784831243 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -10,4 +10,16 @@ function capitalise(str) { } // =============> write your explanation here + +// Looking at the function declaration, it shows that str is already a parameter and has already been declared. +// let cannot declare a new variable in the same scope. Therefore, a syntax error occurs. + + // =============> write your new code here + +// We need to remove let from the function declaration so we can modify the value of the existing str variable + +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} From ba255ad1e70c1d15900b8110663d8445aa94612e Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Wed, 11 Jun 2025 23:14:41 +0100 Subject: [PATCH 30/31] Update 0.js --- Sprint-2/1-key-errors/0.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 784831243..e7079f507 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -11,15 +11,4 @@ function capitalise(str) { // =============> write your explanation here -// Looking at the function declaration, it shows that str is already a parameter and has already been declared. -// let cannot declare a new variable in the same scope. Therefore, a syntax error occurs. - - // =============> write your new code here - -// We need to remove let from the function declaration so we can modify the value of the existing str variable - -function capitalise(str) { - str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} From 3ca5cc194efc57d00ece7d34e32cb024f346873f Mon Sep 17 00:00:00 2001 From: Seddiq Azam Date: Mon, 23 Jun 2025 18:36:30 +0100 Subject: [PATCH 31/31] Update 0.js --- Sprint-2/1-key-errors/0.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index e7079f507..653d6f5a0 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -10,5 +10,4 @@ function capitalise(str) { } // =============> write your explanation here - // =============> write your new code here