From 29b8f8d8e657c8f1fc29c0ff0008e208986b4ba1 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:03:43 +0100 Subject: [PATCH 01/16] add count --- 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..ce4472e92f 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 +// Line 3 is reassigning the value of the variable count by adding 1 to its initial value. +// The = sign is assigning the result of the expression on the right side (count + 1) to the variable count on the left side. From faa06ac803d89cb7de5001ef2891595e000fbdcd Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:03:57 +0100 Subject: [PATCH 02/16] add initials --- Sprint-1/1-key-exercises/2-initials.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..d87717058f 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 - +console.log(initials); \ No newline at end of file From 89a21032191e0beacfd31e4f87cb524a783068f1 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:05:45 +0100 Subject: [PATCH 03/16] add paths --- Sprint-1/1-key-exercises/3-paths.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..e83525371a 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 ext = filePath.slice(filePath.lastIndexOf(".") + 1); + +console.log(dir); +console.log(ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 3c3188f47ab5259558d1806c93b5eda899995d25 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:06:01 +0100 Subject: [PATCH 04/16] add randoms --- Sprint-1/1-key-exercises/4-random.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..9b33559638 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,8 @@ 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 +// num represents a random integer between the minimum and maximum values (inclusive). +// The expression Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive). +// By multiplying this value by (maximum - minimum + 1), we scale it to the desired range. +// The Math.floor() function then rounds this value down to the nearest whole number, ensuring we get an integer. +// Finally, we add the minimum value to shift the range to start from the minimum instead of 0. From 61147c72cc1779107cadf9f3266ba988cfccece5 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:06:26 +0100 Subject: [PATCH 05/16] add errors task 0 --- Sprint-1/2-mandatory-errors/0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..6a7a7f6908 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,2 @@ -This is just an instruction for the first activity - but it is just for human consumption -We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file +// This is just an instruction for the first activity - but it is just for human consumption +// We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file From 6b062a6bb4d15ea86684723ec6a1c5d44dd694df Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:06:55 +0100 Subject: [PATCH 06/16] add errors task1 --- Sprint-1/2-mandatory-errors/1.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea76..6fedd2025e 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,7 @@ // 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; + +let age = 33; +age = age + 1; \ No newline at end of file From 103bc6947656984847c632dcfd7dc8cbce3d86f0 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:07:06 +0100 Subject: [PATCH 07/16] add errors task2 --- Sprint-1/2-mandatory-errors/2.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831d..db5fb19e55 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,10 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? +const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); -const cityOfBirth = "Bolton"; + +// return has not been defined before it is used in the console.log statement. +// To fix this, you should declare and assign a value to the variable cityOfBirth before using it in the console.log statement. +// To do this, you can move the line const cityOfBirth = "Bolton"; above the console.log statement. +// This way, the variable will be defined before it is used, and the code will work as expected. From 5d11b8f66ae854cd637974d7a869e6840e034da1 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:07:22 +0100 Subject: [PATCH 08/16] add errors task3 --- Sprint-1/2-mandatory-errors/3.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884db..28bf86ddcf 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,6 @@ -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 @@ -7,3 +8,5 @@ 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 +// returns an error because the slice method is not available for numbers. The slice method is a string method, and cardNumber is a number. +// To fix this, we need to convert cardNumber to a string before using the slice method. We can do this by using the toString() method or by using template literals. From 7cd725aa2748ea6972e086ac864112f80289c416 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:07:43 +0100 Subject: [PATCH 09/16] add errors task4 --- Sprint-1/2-mandatory-errors/4.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 5f86c730bc..cd8b6fe072 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,9 @@ const 12HourClockTime = "8:53pm"; const 24hourClockTime = "20:53"; + +// 12 Hour clock time is a string that represents the time in 12-hour format, while 24hourClockTime is a string that represents the time in 24-hour format. +// To convert 12HourClockTime to 24-hour format, we can use the following steps: +// 1. Split the string into hours and minutes using the split() method. +// 2. Check if the time is in the "pm" period. If it is, add 12 to the hours (unless it's 12pm). +// 3. If the time is in the "am" period and the hour is 12, set the hour to 0. +// 4. Format the hours and minutes into a string in 24-hour format. \ No newline at end of file From 79e144472dfa23f620cb033a1f33ced53750da63 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:08:11 +0100 Subject: [PATCH 10/16] add time format --- Sprint-1/3-mandatory-interpret/2-time-format.js | 7 +++++++ 1 file changed, 7 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..d98e24bc97 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -8,6 +8,13 @@ const totalHours = (totalMinutes - remainingMinutes) / 60; const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; console.log(result); +// There are 6 variables declared in this program: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result. +// There are 4 function calls in this program: console.log(), and the three arithmetic operations used to calculate remainingSeconds, totalMinutes, and remainingMinutes. +// The expression movieLength % 60 calculates the remainder when movieLength is divided by 60. This gives the number of seconds remaining after converting the total length of the movie into minutes and hours. +// Interpret line 4, the expression assigned to totalMinutes calculates the total number of minutes in the movie by subtracting the remaining seconds from the total length of the movie and dividing by 60. +// The variable result represents the formatted string of the movie length in hours, minutes, and seconds. A better name for this variable could be formattedMovieLength or movieLengthString. +// This code will work for all values of movieLength, as it correctly calculates the hours, minutes, and seconds regardless of the total length of the movie. However, if movieLength is negative, it may not produce a meaningful result. +// experimenting with different values of movieLength, such as 2:25.833, 1:23:20, will show that the code correctly formats the length of the movie in hours, minutes, and seconds for all positive values. // For the piece of code above, read the code and then answer the following questions From 6fca6cbd540b387914b4883f6e15879a6e254238 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 15 Jul 2026 17:09:01 +0100 Subject: [PATCH 11/16] add to pounds --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 8 +++++++- 1 file changed, 7 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 60c9ace69a..66e0d2fb48 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -17,7 +17,7 @@ const pence = paddedPenceNumberString console.log(`£${pounds}.${pence}`); -// This program takes a string representing a price in pence +// This program takes a string representindng a price in pence // The program then builds up a string representing the price in pounds // You need to do a step-by-step breakdown of each line in this program @@ -25,3 +25,9 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// const penceString = "399p": initialises a string variable with the value "399p" +// 1. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1): creates a new string variable that removes the last character "p" from the original string +// 2. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): creates a new string variable that pads the original string with leading zeros to make it 3 characters long +// 3. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds portion of the string by taking all characters except the last two +// 4. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence portion of the string by taking the last two characters and pads it with trailing zeros to make it 2 characters long +// 5. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence to the console \ No newline at end of file From 1cd3d6da681730c93ebb7e4e867bba4b25e05c8e Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Thu, 16 Jul 2026 15:15:47 +0100 Subject: [PATCH 12/16] fix errors without changes --- Sprint-1/2-mandatory-errors/3.js | 4 ++-- Sprint-2/1-key-errors/0.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index 28bf86ddcf..8d5d6b276b 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.toString().slice(-4); console.log(last4Digits); // The last4Digits variable should store the last 4 digits of cardNumber diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..4b806b91ba 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -4,10 +4,16 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring +// function capitalise(str) { +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } + +// =============> str has already been declared in the function. +// =============> function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; + str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } -// =============> write your explanation here -// =============> write your new code here +console.log(capitalise("tommy is a good boy")); From 577580918f3a131d2e4775e136da690550576e9d Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Thu, 16 Jul 2026 15:24:47 +0100 Subject: [PATCH 13/16] fix error in 4js --- Sprint-1/2-mandatory-errors/4.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index cd8b6fe072..cd0b28a0d8 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,9 +1,9 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const twelveHourClockTime = "8:53pm"; +const twentyFourHourClockTime = "20:53"; // 12 Hour clock time is a string that represents the time in 12-hour format, while 24hourClockTime is a string that represents the time in 24-hour format. // To convert 12HourClockTime to 24-hour format, we can use the following steps: // 1. Split the string into hours and minutes using the split() method. // 2. Check if the time is in the "pm" period. If it is, add 12 to the hours (unless it's 12pm). // 3. If the time is in the "am" period and the hour is 12, set the hour to 0. -// 4. Format the hours and minutes into a string in 24-hour format. \ No newline at end of file +// 4. Format the hours and minutes into a string in 24-hour format. From 1bf7cd3311b9722bd0d61cc01ffab52873ce1735 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Thu, 16 Jul 2026 16:12:44 +0100 Subject: [PATCH 14/16] fix errors in time --- Sprint-1/3-mandatory-interpret/2-time-format.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index d98e24bc97..599e98dfe2 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -8,13 +8,6 @@ const totalHours = (totalMinutes - remainingMinutes) / 60; const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; console.log(result); -// There are 6 variables declared in this program: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result. -// There are 4 function calls in this program: console.log(), and the three arithmetic operations used to calculate remainingSeconds, totalMinutes, and remainingMinutes. -// The expression movieLength % 60 calculates the remainder when movieLength is divided by 60. This gives the number of seconds remaining after converting the total length of the movie into minutes and hours. -// Interpret line 4, the expression assigned to totalMinutes calculates the total number of minutes in the movie by subtracting the remaining seconds from the total length of the movie and dividing by 60. -// The variable result represents the formatted string of the movie length in hours, minutes, and seconds. A better name for this variable could be formattedMovieLength or movieLengthString. -// This code will work for all values of movieLength, as it correctly calculates the hours, minutes, and seconds regardless of the total length of the movie. However, if movieLength is negative, it may not produce a meaningful result. -// experimenting with different values of movieLength, such as 2:25.833, 1:23:20, will show that the code correctly formats the length of the movie in hours, minutes, and seconds for all positive values. // For the piece of code above, read the code and then answer the following questions @@ -30,3 +23,11 @@ console.log(result); // 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 + +//There are 6 variables declared in this program: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result. +// There is 1 function calls in this program: console.log(), and the three arithmetic operations used to calculate remainingSeconds, totalMinutes, and remainingMinutes. +// The expression movieLength % 60 calculates the remainder when movieLength is divided by 60. This gives the number of seconds remaining after converting the total length of the movie into minutes and hours. +// Interpret line 4, the expression assigned to totalMinutes calculates the total number of minutes in the movie by subtracting the remaining seconds from the total length of the movie and dividing by 60. +// The variable result represents the formatted string of the movie length in hours, minutes, and seconds. A better name for this variable could be formattedMovieLength or movieLengthString. +// This code will work for all values of movieLength. +// experimenting with different values of movieLength, such as 1:51:6, 0:55:33 etc., will show that the code correctly formats the length of the movie in hours, minutes, and seconds for all positive values. From 06643597cd23a37bf73af2df2d288928b06c4b20 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Thu, 16 Jul 2026 16:20:22 +0100 Subject: [PATCH 15/16] fix all errors --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 2 +- 1 file changed, 1 insertion(+), 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 66e0d2fb48..47306ccb23 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -30,4 +30,4 @@ console.log(`£${pounds}.${pence}`); // 2. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"): creates a new string variable that pads the original string with leading zeros to make it 3 characters long // 3. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2): extracts the pounds portion of the string by taking all characters except the last two // 4. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"): extracts the pence portion of the string by taking the last two characters and pads it with trailing zeros to make it 2 characters long -// 5. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence to the console \ No newline at end of file +// 5. console.log(`£${pounds}.${pence}`): outputs the final formatted price in pounds and pence to the console From 23f39316d6ad59a925806a06e28d9f5eb4786927 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Fri, 17 Jul 2026 13:14:51 +0100 Subject: [PATCH 16/16] fix wrong edited file --- Sprint-2/1-key-errors/0.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 4b806b91ba..653d6f5a07 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -4,16 +4,10 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -// function capitalise(str) { -// let str = `${str[0].toUpperCase()}${str.slice(1)}`; -// return str; -// } - -// =============> str has already been declared in the function. -// =============> function capitalise(str) { - str = `${str[0].toUpperCase()}${str.slice(1)}`; + let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } -console.log(capitalise("tommy is a good boy")); +// =============> write your explanation here +// =============> write your new code here