From 37a0f597cf340f207aedd07c12d927ca2c74a3e4 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 12 Sep 2026 14:27:21 +0100 Subject: [PATCH 01/14] Adding answers for 1-count.js --- Sprint-2/1-key-exercises/1-count.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..d94416aed 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -4,3 +4,8 @@ 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 + +/* +it is making count be the sum of count + 1. +For example if this is part of a loop it will allow count to keep adding 1 each time the loop runs. +*/ \ No newline at end of file From c0c59e965638154902866198306794fa612abb12 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Sat, 12 Sep 2026 15:36:32 +0100 Subject: [PATCH 02/14] Done task for 2-initials.js --- Sprint-2/1-key-exercises/2-initials.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 964c9563c..58487de2d 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,6 +5,6 @@ const 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. -const initials = ``; +const initials = firstName.slice(0,1) + middleName.slice(0,1) + lastName.slice(0,1); // https://www.google.com/search?q=get+first+character+of+string+mdn From 5f618f9c298b87a08c911e10d77cb94116e966f8 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 16:55:37 +0100 Subject: [PATCH 03/14] completed codes for 3-paths.js --- Sprint-2/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ab90ebb28..9247b2fcc 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/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, filePath.lastIndexOf("/") + 1); +const ext = filePath.slice(-4); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 14355acc68c88684a6cca2c23ba7ed4d1485d313 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:15:42 +0100 Subject: [PATCH 04/14] Done the answers for 4-random.js Added // console.log(num); to be able to see code generation --- Sprint-2/1-key-exercises/4-random.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..02fd9eb99 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -3,7 +3,15 @@ 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 +/* +Firstly its not running as it is showing as undefined as it is lacking something like console.log +After adding console.log(num) and running it a few times I get 62, 45, 35, 10. +For what it is doing: Math.floor is the sum of a random number from 0 to 0.9999... which is then multiplied by the maxium - minimun + 1, so 100 - 1 + 1. + That gives a number from 0-99, then then adds the minimun which is 1, so that gives a random number from 1-100. +*/ \ No newline at end of file From cf5f0dc4b6d0ca97ae28b33d89a3ec337040e3a7 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:21:31 +0100 Subject: [PATCH 05/14] Found error and added comment for 0.js --- Sprint-2/2-mandatory-errors/0.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..a5a9b16b3 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/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 +We don't want the computer to run these 2 lines - how can we solve this problem? + +// giving SyntaxError +// You need to add // to each line or /* before the first line and */ after the last one to make it a comment. \ No newline at end of file From a50c7a72892eb5c18008c8e2ecd859f5213b2475 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:26:08 +0100 Subject: [PATCH 06/14] TypeError for 1.js Given comment and suggestion --- Sprint-2/2-mandatory-errors/1.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..7d61b7dd4 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -2,3 +2,11 @@ const age = 33; age = age + 1; + +// this gives a TypeError +// age is already a const at the start and calling it again just as age wont work, naming it like "older" would work better: + +// const age = 33; +// let older = (age + 1); +// console.log(older) + From 4c7f5d9dae70be994464da35765323c9c3830286 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:28:50 +0100 Subject: [PATCH 07/14] ReferenceError for 2.js Order of the code was incorrect and showed suggestion to fix. --- Sprint-2/2-mandatory-errors/2.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..65c766f8a 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/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 ? -console.log(`I was born in ${cityOfBirth}`); +// console.log(`I was born in ${cityOfBirth}`); +// const cityOfBirth = "Bolton"; + +//ReferenceError is happening + const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); From 04de5cb52262cad39c84a3b69da14bf95a48db47 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:40:30 +0100 Subject: [PATCH 08/14] Error for 2.js is ReferenceError and gave suggestion Error for 3.js is TypeError and added code that would run it. --- Sprint-2/2-mandatory-errors/2.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index 65c766f8a..f389327b6 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,10 +1,10 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? -// console.log(`I was born in ${cityOfBirth}`); -// const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); +const cityOfBirth = "Bolton"; -//ReferenceError is happening +//ReferenceError is happening as the const is after the console.log request for it, so the order is wrong. -const cityOfBirth = "Bolton"; -console.log(`I was born in ${cityOfBirth}`); +// const cityOfBirth = "Bolton"; +// console.log(`I was born in ${cityOfBirth}`); From a1b1cf81a4054ed150a1b0a7e36ccaa71463c75f Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:41:07 +0100 Subject: [PATCH 09/14] changed // --- Sprint-2/2-mandatory-errors/3.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..efd5f0ad6 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,5 +1,5 @@ -const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +// const cardNumber = 4533787178994213; +// const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -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 + +/* +cardNumber is giving a number and that can't be used for slice, could not remember the name for that error at this time. +after running the code it shows thats a TypeError. cardNumber.slice is not a function +*/ + +const cardNumber = 4533787178994213; +let number = cardNumber.toString() +const last4Digits = number.slice(-4); +console.log(last4Digits) + + + From 1dc53ce2212bd2de3f07c9fc9ed3418db8517021 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Tue, 15 Sep 2026 17:47:25 +0100 Subject: [PATCH 10/14] this is a SyntaxError for 4.js Added suggested code for fix --- Sprint-2/2-mandatory-errors/4.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..4389885a7 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,8 @@ const 12HourClockTime = "8:53pm"; const 24hourClockTime = "20:53"; + +// This is a Syntax error as cant have numbers for an identifier at the start of it. +// Changing to say: time12HourClock would work + +// const time12HourClock = "8:53pm"; +// const time24hourClock = "20:53"; \ No newline at end of file From 647c50a9bde139e1d5078932666b8af7d28ff155 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Wed, 16 Sep 2026 11:25:43 +0100 Subject: [PATCH 11/14] Answered the questions in the comments area in 1-percentage-change.js --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..85382a705 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,19 @@ 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 + // 5 times its been called: + // 4 and 5 for Number and replaceAll + // 10 for 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? + // SyntaxError, its from line 5 in replaceAll("," "") + // its missing a , between the two arguments so it needs to be (",", "") // c) Identify all the lines that are variable reassignment statements + // There are two reassignment statements in lines 4 and 5 // d) Identify all the lines that are variable declarations - + // They are 1,2 and 7,8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + // It is using Number to make the string into a number but in order to do that the string needs to contain numerical letters only. + // So it then uses in the () to remove all of the , with nothing using the replaceAll function so that 10,000 becomes 10000 \ No newline at end of file From 29409f8c22b8a0d2647623b60b60a97b040d3a3b Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Wed, 16 Sep 2026 11:26:27 +0100 Subject: [PATCH 12/14] added a spaced line at 28 to make it easier to read for comments --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 85382a705..f050f3c7a 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -25,6 +25,7 @@ console.log(`The percentage change is ${percentageChange}`); // d) Identify all the lines that are variable declarations // They are 1,2 and 7,8 + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? // It is using Number to make the string into a number but in order to do that the string needs to contain numerical letters only. // So it then uses in the () to remove all of the , with nothing using the replaceAll function so that 10,000 becomes 10000 \ No newline at end of file From 655acb66f45c4b7fe63e97b482f19446c1d68fc4 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Wed, 16 Sep 2026 11:40:28 +0100 Subject: [PATCH 13/14] Answered questions in 2-time-format.js --- .../3-mandatory-interpret/2-time-format.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 47d239558..0ddede88e 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -1,25 +1,32 @@ -const movieLength = 8784; // length of movie in seconds +// const movieLength = 8784; // length of movie in seconds -const remainingSeconds = movieLength % 60; -const totalMinutes = (movieLength - remainingSeconds) / 60; +// const remainingSeconds = movieLength % 60; +// const totalMinutes = (movieLength - remainingSeconds) / 60; -const remainingMinutes = totalMinutes % 60; -const totalHours = (totalMinutes - remainingMinutes) / 60; +// const remainingMinutes = totalMinutes % 60; +// const totalHours = (totalMinutes - remainingMinutes) / 60; -const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; -console.log(result); +// const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; +// 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 6 variable declarations, lines 1,3,4,6,7,9 // b) How many function calls are there? + //1 at line 10 // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators + //This is using a remainder, this us seeing how many times 8784 goes into 60 and what is remaining which is 24 in this case: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder // d) Interpret line 4, what does the expression assigned to totalMinutes mean? + // It is the sum of movieLength minus remainingSeconds then divided by 60 // e) What do you think the variable result represents? Can you think of a better name for this variable? + // its showing the length of the movie in hours, minutes and seconds, could be better called something like MovieDuration // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + //Yes it will as long as the input is numerical numbers only, it does not work with any extra symbols, spaces or letters. From 1d0edb2c4fe411b7a1b41c468ae5464c99b9f6f7 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Wed, 16 Sep 2026 12:06:33 +0100 Subject: [PATCH 14/14] answered the questions to 3-to-pounds.js --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..db4abf51e 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,24 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +/* +3-6. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1) + This is taking penceString and removing the p from it so its just a string with the numerical letters only. + +8. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + This is taking penceStringWithoutTrailingP ensuring that the minimum length of the numerical string is at least 3 numbers. + It is filling out with 0s from the front so if it was 3 it would have 003 + +9-12. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); + this is taking paddedPenceNumberString and removing the last 2 numerical numbers from the string/ + This takes the 399 and makes it 3 + + +14-16. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); + This is taking paddedPenceNumberString and first reduces the length to the last 2 numbers in the string. + It then uses padEnd to ensure that there is a at least two 00 if no numbers are present. + +18. console.log(`£${pounds}.${pence}`); + This shows the pounds and pence with a £ at the start and a . between them. + making this show the pence to pounds as £3.99 +*/ \ No newline at end of file