From 96d622c69956a38b5c42fb478b522cb51198ce66 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 12:01:45 +0000 Subject: [PATCH 01/40] :wq Updating the script with comments detailing my understanding of the script :wq --- Sprint-1/1-key-exercises/1-count.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..7737ea4fd 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,7 @@ 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 +// The '=' assignment operator. It assigns the value on the right hand side to the variable on the left. +// The variable 'count' is initially assigned the value of 0. +// And the result is assigned back to count. +// This mean 'count; is updated each time this line runs. \ No newline at end of file From 3bb281b1e04a9fb5c2b26aacf3f8cdb0a816ec55 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 14:41:40 +0000 Subject: [PATCH 02/40] Adding in the code to satify the intials challenge --- Sprint-1/1-key-exercises/2-initials.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..9fc5dc79b 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 = ``; - -// https://www.google.com/search?q=get+first+character+of+string+mdn +let initials = firstName[0] + middleName[0] + lastName[0]; +console.log(initials); +// https://www.google.com/search?q=get+first+character+of+string+mdn \ No newline at end of file From 1dc12f72ff6cbcd0a42dd1d439a296a4b258ea65 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 14:57:13 +0000 Subject: [PATCH 03/40] Adding in the explination of my solution --- Sprint-1/1-key-exercises/2-initials.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 9fc5dc79b..919ba4ca5 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -8,4 +8,8 @@ let lastName = "Johnson"; let initials = firstName[0] + middleName[0] + lastName[0]; console.log(initials); -// https://www.google.com/search?q=get+first+character+of+string+mdn \ No newline at end of file +// https://www.google.com/search?q=get+first+character+of+string+mdn +// Explaning the solution: I assign 'initials' to a new string variable made by combining the +// first character of 'firstName', 'middleName' and 'lastName'. +// Strings in JavaScript are indexable, so using [0] accesses the first +// character of each string. \ No newline at end of file From 1ef3a27ce900292d6d69ec1147e864dae29ad867 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 15:04:47 +0000 Subject: [PATCH 04/40] Updating const ext with the the relevant code --- Sprint-1/1-key-exercises/3-paths.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..36ba95918 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -12,12 +12,12 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; const lastSlashIndex = filePath.lastIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); -console.log(`The base part of ${filePath} is ${base}`); +//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 = ; +const ext = filePath.slice(lastSlashIndex + 5); +console.log(ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 5c23704758605ea6dd34e002e8d96eb8fa86b27c Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 15:16:21 +0000 Subject: [PATCH 05/40] Committing an attempt to figure out the issue --- Sprint-1/1-key-exercises/3-paths.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 36ba95918..d7c0f5498 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -10,14 +10,16 @@ // (All spaces in the "" line should be ignored. They are purely for formatting.) const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; -const lastSlashIndex = filePath.lastIndexOf("/"); +//const lastSlashIndex = filePath.lastIndexOf("/"); +const firstSlashIndex = filePath.firstIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); //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 = filePath.slice(lastSlashIndex + 5); -console.log(ext); +const dir = filePath.slice(firstSlashIndex + 1); +console.log(dir); +//const ext = filePath.slice(lastSlashIndex + 5); +//console.log(ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 2f85b848c19a5a5aef0aa5158c588b979d65a6e4 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 15:26:41 +0000 Subject: [PATCH 06/40] Committing solution for dir pathway --- Sprint-1/1-key-exercises/3-paths.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index d7c0f5498..20d810a72 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -10,16 +10,15 @@ // (All spaces in the "" line should be ignored. They are purely for formatting.) const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; -//const lastSlashIndex = filePath.lastIndexOf("/"); -const firstSlashIndex = filePath.firstIndexOf("/"); +const lastSlashIndex = filePath.lastIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); -//console.log(`The base part of ${filePath} is ${base}`); +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 = filePath.slice(firstSlashIndex + 1); -console.log(dir); -//const ext = filePath.slice(lastSlashIndex + 5); -//console.log(ext); +const dir = filePath.slice(0, lastSlashIndex); +//const ext = ; + +console.log("Dir:", dir); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 96f937931f0a911c6254abec335a9f39aeb303da Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 15:51:59 +0000 Subject: [PATCH 07/40] Committing solution for EXT --- Sprint-1/1-key-exercises/3-paths.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 20d810a72..254445f80 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -12,13 +12,15 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; const lastSlashIndex = filePath.lastIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); +const lastDotIndex = filePath.lastIndexOf("."); 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 = filePath.slice(0, lastSlashIndex); -//const ext = ; +const ext = filePath.slice(lastDotIndex + 1); console.log("Dir:", dir); +console.log("Ext:", ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 8e18c54ad401b91d9fdf54d510e5858355a097dd Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:19:23 +0000 Subject: [PATCH 08/40] Commiting the solution description --- Sprint-1/1-key-exercises/3-paths.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 254445f80..d2a1dfd38 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -23,4 +23,8 @@ const ext = filePath.slice(lastDotIndex + 1); console.log("Dir:", dir); console.log("Ext:", ext); -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +// https://www.google.com/search?q=slice+mdn +//Explaining the solution: lastIndexOf() is used to locate boundaries (/ and .) +// slice() is used to extract the required parts of the string. +// No values are hard-coded, so the solution works for similar file paths. +// The result correctly seperats the path into dir and ext. \ No newline at end of file From f29be1416d543ed0c2dd115b1acd953ad23ced53 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:24:36 +0000 Subject: [PATCH 09/40] Adding punctuation --- Sprint-1/1-key-exercises/3-paths.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index d2a1dfd38..c15498357 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -24,7 +24,7 @@ const ext = filePath.slice(lastDotIndex + 1); console.log("Dir:", dir); console.log("Ext:", ext); // https://www.google.com/search?q=slice+mdn -//Explaining the solution: lastIndexOf() is used to locate boundaries (/ and .) +// Explaining the solution: lastIndexOf() is used to locate boundaries (/ and .) // slice() is used to extract the required parts of the string. // No values are hard-coded, so the solution works for similar file paths. // The result correctly seperats the path into dir and ext. \ No newline at end of file From c70429e07a5216b6456ed68d1299627569f9d4bc Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:31:00 +0000 Subject: [PATCH 10/40] Logging the const num to terminal to understand the result --- Sprint-1/1-key-exercises/4-random.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..7730b710a 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -2,8 +2,9 @@ const minimum = 1; 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 +// Explaning the solution: console.log(num); returns a number. \ No newline at end of file From abee58956af17c9d000945b8ba6ddf531d43a1b3 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:33:38 +0000 Subject: [PATCH 11/40] Experimenting with Math.Floor by logging the output of a random float to the terminal --- Sprint-1/1-key-exercises/4-random.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 7730b710a..3691197fb 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -2,9 +2,10 @@ const minimum = 1; const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; -console.log(num); +console.log(Math.floor(0.5)); // 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 -// Explaning the solution: console.log(num); returns a number. \ No newline at end of file +// Explaning the solution: console.log(num); returns a number. +// Upon investigation Math.Floor - returns and whole int that is the less than or equal to its numeric argument. \ No newline at end of file From 6d126ff2476c6b1b1a4b75843cddb48882fac8a2 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:35:29 +0000 Subject: [PATCH 12/40] Experimenting with Math.random by logging the output within the terminal --- Sprint-1/1-key-exercises/4-random.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 3691197fb..481cf3e97 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -2,10 +2,11 @@ const minimum = 1; const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; -console.log(Math.floor(0.5)); +console.log(Math.random()); // 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 // Explaning the solution: console.log(num); returns a number. -// Upon investigation Math.Floor - returns and whole int that is the less than or equal to its numeric argument. \ No newline at end of file +// Upon investigation Math.Floor - returns and whole int that is the less than or equal to its numeric argument. +// Math.randon - returns a random float/int \ No newline at end of file From 0e510601ab00b9c02a1f55039290bf8094b217d7 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:38:54 +0000 Subject: [PATCH 13/40] Adding the explination of the solution for this activity --- Sprint-1/1-key-exercises/4-random.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 481cf3e97..abe8b41f5 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -2,11 +2,13 @@ const minimum = 1; const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; -console.log(Math.random()); +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 // Explaning the solution: console.log(num); returns a number. // Upon investigation Math.Floor - returns and whole int that is the less than or equal to its numeric argument. -// Math.randon - returns a random float/int \ No newline at end of file +// Math.randon - returns a random float/int +// Now putting my understanding together - I understand that the const num when logged using console.log returns a value in this order +// A number at random is chosen and is multiplied with the maximum value (of that number) - the minimum value is then added to one (+ 1) and then added to the minimum of the total. \ No newline at end of file From fb5e6ee2b749f36323c6a3f26941e85fd9c675a2 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:40:52 +0000 Subject: [PATCH 14/40] Commenting out the lines using the js syntax --- 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 cf6c5039f..65ad3030d 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 04483658847caa5e12acb5c2330c83d20ddb04bb Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:44:33 +0000 Subject: [PATCH 15/40] Updating the script with a potential solution --- Sprint-1/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..9479f8742 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = Math.floor(Math.random()); age = age + 1; +console.log(age); From df44244c0875478527738d2b1bffe6d71e7568ca Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:47:30 +0000 Subject: [PATCH 16/40] Adding in the explaination of the solution --- Sprint-1/2-mandatory-errors/1.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 9479f8742..102667f82 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -3,3 +3,6 @@ let age = Math.floor(Math.random()); age = age + 1; console.log(age); +// Explaning the solution: Assigning age to a variable that is not constant - then utalising Math.Floor and Math.Random to assign age a whole random number. +// I then allow age to be added to 1 +// I then log to the console to verify the age. \ No newline at end of file From 98566d0c73dae4291ef2f4407a212a46ab0dd86a Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:48:59 +0000 Subject: [PATCH 17/40] Updating the code with the solution --- 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..a7401245d 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}`); \ No newline at end of file From 932aea59ac6ed258ca04319ce3ab9b241816d5d8 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 16:57:15 +0000 Subject: [PATCH 18/40] Adding the prediction --- Sprint-1/2-mandatory-errors/3.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..b1e170494 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -7,3 +7,4 @@ 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 +// Prediction: The code may not work due to the const variable being an int. The slice method usually works on strings. From 5a6944423d1f20c07bc671bb0b356642d406d7cd Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sat, 7 Feb 2026 17:01:22 +0000 Subject: [PATCH 19/40] Updating the solution with the correct code --- Sprint-1/2-mandatory-errors/3.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index b1e170494..aec264a30 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,6 +1,7 @@ const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +const last4Digits = cardNumber.toString().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 @@ -8,3 +9,4 @@ const last4Digits = cardNumber.slice(-4); // 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 // Prediction: The code may not work due to the const variable being an int. The slice method usually works on strings. +// Updating the const last4Digits with .toString() allowed the const cardNumber to convert from int to string and therefore the solution works as expected. From 45f99535a935dba60019901ac42b3e71c43a1aa3 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 8 Feb 2026 16:02:59 +0000 Subject: [PATCH 20/40] Correcting the syntax --- Sprint-1/2-mandatory-errors/4.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..29f7f43fe 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,5 @@ -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); +console.log(twentyFourHourClockTime); \ No newline at end of file From fb5cc26231747dee8eba2940f40d0182704b6541 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 8 Feb 2026 16:05:42 +0000 Subject: [PATCH 21/40] Adding the explination of the solution --- Sprint-1/2-mandatory-errors/4.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 29f7f43fe..b5e407f64 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -2,4 +2,5 @@ const twelveHourClockTime = "20:53"; const twentyFourHourClockTime = "08:53"; console.log(twelveHourClockTime); -console.log(twentyFourHourClockTime); \ No newline at end of file +console.log(twentyFourHourClockTime); +//Explaining the solution: The issue is that the syntax to assign a const var needs to be a string. \ No newline at end of file From 9792b2249e8603588fd461d9b8fd63473b8b3a68 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 8 Feb 2026 16:30:21 +0000 Subject: [PATCH 22/40] Fixing syntax issue for the priceAfteOneYear function --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 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..5de10319e 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; From aa822ed7f2a25ff7a0f21690eab7f9067447e7df Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 8 Feb 2026 16:54:49 +0000 Subject: [PATCH 23/40] Updating question a) with the ans --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 5de10319e..1e6369808 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -12,6 +12,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 a total of 5 different function calls: carPrice = replaceAll(",", ""));, priceAfterOneYear = replaceAll(",", ""));, +// Number(carPrice), Number(priceAfterOneYear, console.log(`The percentage change is ${percentageChange}`);. // 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? From 2acccaa714e368a87b084fb5ad25437acec2f241 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 8 Feb 2026 19:48:18 +0000 Subject: [PATCH 24/40] Updating question b) and c) with the ans --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 1e6369808..83d5b29e6 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -16,6 +16,7 @@ console.log(`The percentage change is ${percentageChange}`); // Number(carPrice), Number(priceAfterOneYear, console.log(`The percentage change is ${percentageChange}`);. // 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 syntax error is originating on line 5, this is due to a missing ',' in the function priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));. // c) Identify all the lines that are variable reassignment statements From 71506f741affc37d9c043f16d2ff2770db9ec164 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Sun, 8 Feb 2026 19:49:47 +0000 Subject: [PATCH 25/40] updating question d) with the ans --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 4 +++- 1 file changed, 3 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 83d5b29e6..24735f51e 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -16,10 +16,12 @@ console.log(`The percentage change is ${percentageChange}`); // Number(carPrice), Number(priceAfterOneYear, console.log(`The percentage change is ${percentageChange}`);. // 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 syntax error is originating on line 5, this is due to a missing ',' in the function priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));. +// The syntax error is originating on line 5, this is due to a missing ',' in the function priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));. // c) Identify all the lines that are variable reassignment statements +// The lines that are vvariable declarations use let or const: carPrice, priceAfterOneYear. // d) Identify all the lines that are variable declarations +// The lines that are vvariable declarations use let or const: let carPrice, let priceAfterOneYear, const priceDifference and const percentageChange. // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? From 276e42a22f69e771427e3dcd5361027c8d67fc0f Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 10:54:53 +0000 Subject: [PATCH 26/40] General clean up of the tasks, and correcting some spelling erros --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index 24735f51e..deca81cd4 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -25,3 +25,6 @@ console.log(`The percentage change is ${percentageChange}`); // The lines that are vvariable declarations use let or const: let carPrice, let priceAfterOneYear, const priceDifference and const percentageChange. // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// This particular expression is doing two steps. First it takes "10,000" and removes the commas so the output then is "10000" +// THe second step converts the the string into a number - this is likely because the next function then subtracts the number to find the difference between +// carPrice and priceAfterOneYear and stores it within priceDifference variable declaration. \ No newline at end of file From 0ff59581101443c9c59866ae60d066e0d2ca87cb Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 10:56:57 +0000 Subject: [PATCH 27/40] Updating some spelling errors --- .../1-percentage-change.js | 18 +++++++++++------- 1 file changed, 11 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 deca81cd4..c093ce682 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -11,20 +11,24 @@ 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 a total of 5 different function calls: carPrice = replaceAll(",", ""));, priceAfterOneYear = replaceAll(",", ""));, -// Number(carPrice), Number(priceAfterOneYear, console.log(`The percentage change is ${percentageChange}`);. +// a) How many function calls are there in this file? +// 1) carPrice.replaceAll(",", "") +// 2) Number(carPrice.replaceAll(",", "")) +// 3) priceAfterOneYear.replaceAll(",", "") +// 4) Number(priceAfterOneYear.replaceAll(",", "")) +// 5) console.log(`The percentage change is ${percentageChange}`); // 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 syntax error is originating on line 5, this is due to a missing ',' in the function priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));. +// The syntax error is originating on line 5, this error occurs because replaceAll is missing ',' in between the arguments - priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," , ""));. // c) Identify all the lines that are variable reassignment statements -// The lines that are vvariable declarations use let or const: carPrice, priceAfterOneYear. +// carPrice = Number(carPrice.replaceAll(",", "")); +// priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // d) Identify all the lines that are variable declarations -// The lines that are vvariable declarations use let or const: let carPrice, let priceAfterOneYear, const priceDifference and const percentageChange. +// The lines that are variable declarations use let or const: let carPrice, let priceAfterOneYear, const priceDifference and const percentageChange. // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? // This particular expression is doing two steps. First it takes "10,000" and removes the commas so the output then is "10000" -// THe second step converts the the string into a number - this is likely because the next function then subtracts the number to find the difference between +// The second step converts the the string into a number - this is likely because the next function then subtracts the number to find the difference between // carPrice and priceAfterOneYear and stores it within priceDifference variable declaration. \ No newline at end of file From 50c9bab0ff4f3f9894135e6f44b242052259fd4f Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:00:07 +0000 Subject: [PATCH 28/40] Committing the ans to question a) --- 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 47d239558..50276f23f 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,6 +12,13 @@ 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? +//This program has 6 variable declarations: +//const movieLength = 8784; +//const remainingSeconds = movieLength % 60; +//const totalMinutes = (movieLength - remainingSeconds) / 60; +//const remainingMinutes = totalMinutes % 60; +//const totalHours = (totalMinutes - remainingMinutes) / 60; +//const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; // b) How many function calls are there? From 1cd9a528d14040a0d364f7338f9f4eb227e6925b Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:01:07 +0000 Subject: [PATCH 29/40] Commiting the ans for question b) --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 50276f23f..cf437aa30 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -21,6 +21,8 @@ console.log(result); //const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; // b) How many function calls are there? +// There is 1 function call within this program +//1) console.log(result); // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators From 40c11583d224cb4fa50e4ebb814450621a3b5e41 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:16:57 +0000 Subject: [PATCH 30/40] Committing the ans for c) --- Sprint-1/3-mandatory-interpret/2-time-format.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index cf437aa30..8588183b6 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -26,6 +26,7 @@ console.log(result); // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +// The modulus operator returns the remainder after dividing movieLength by 60. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? From 78cefed7168046533bc2d4644b396fcf58516a53 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:18:57 +0000 Subject: [PATCH 31/40] Commiting the ans to d) --- Sprint-1/3-mandatory-interpret/2-time-format.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 8588183b6..c36b16fdc 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -29,6 +29,10 @@ console.log(result); // The modulus operator returns the remainder after dividing movieLength by 60. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// remainingSeconds removes leftover seconds +// movieLength - remainingSeconds leave only full seconds +// Dividing by 60 converts secods to minutes +// This expression converts the total movie length from seconds into whole minutes, excluding any leftover second. // e) What do you think the variable result represents? Can you think of a better name for this variable? From b43117dec7ab4f0dc596f0fd3a7f28614cd55c4d Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:22:23 +0000 Subject: [PATCH 32/40] Committing the ans to e) --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index c36b16fdc..3e29c1080 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -35,5 +35,7 @@ console.log(result); // This expression converts the total movie length from seconds into whole minutes, excluding any leftover second. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// The variable result represents the formatted movie duration into hours, minutres and seconds. +// A better variable name may be: movieDuration // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer From e7c4a5b7f175d564166887383d4ee0bc03246c83 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:26:16 +0000 Subject: [PATCH 33/40] Committing ans for f) --- Sprint-1/3-mandatory-interpret/2-time-format.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 3e29c1080..2bd66e5ab 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 = -4382.3817; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -39,3 +39,5 @@ console.log(result); // A better variable name may be: movieDuration // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// Upon experimenting with the const movieLength I have tested edge cases. The code works well for positive integer values. +// Handling edge cases such as negative value, floats lead to confusing results. \ No newline at end of file From 85cc2a9b590488f4737f99d00f9b96d040a88fcc Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:29:19 +0000 Subject: [PATCH 34/40] Reviewing and updating spelling typo --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 2bd66e5ab..59d19202c 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -31,7 +31,7 @@ console.log(result); // d) Interpret line 4, what does the expression assigned to totalMinutes mean? // remainingSeconds removes leftover seconds // movieLength - remainingSeconds leave only full seconds -// Dividing by 60 converts secods to minutes +// Dividing by 60 converts seconds to minutes // This expression converts the total movie length from seconds into whole minutes, excluding any leftover second. // e) What do you think the variable result represents? Can you think of a better name for this variable? From 4f2663aa99b0f959aae14c0694ebb16f34a9b1bb Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:43:53 +0000 Subject: [PATCH 35/40] Committing the explination of the program as step 2 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 7 +++++++ 1 file changed, 7 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..d98e28b04 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,10 @@ 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); +// penceString.length -1: points to the index just before the last character. The substring(0, ect) takes everything from the start up to the last character (but not including the last character) +// The result removes th trailing "p" so the output becomes "399p" --> "399" + +// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");: + From 40ddf447c9873d9c8d6ae9c08540c470a517f831 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:46:02 +0000 Subject: [PATCH 36/40] Committing the explinati on of the program as step 3 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index d98e28b04..cd60d79a7 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -31,4 +31,6 @@ console.log(`£${pounds}.${pence}`); // The result removes th trailing "p" so the output becomes "399p" --> "399" // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");: +// Ensures the pence int has at least 3 characters by adding leading zeros if required. +// This is useful for values under 100p so the pounds/pence split works accurately. From 9d6da7a00eac4d7bc9e7f6ea6304471df98147e0 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 11:47:23 +0000 Subject: [PATCH 37/40] Committing the explinati on of the program as step 4 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index cd60d79a7..cf557461f 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -34,3 +34,7 @@ console.log(`£${pounds}.${pence}`); // Ensures the pence int has at least 3 characters by adding leading zeros if required. // This is useful for values under 100p so the pounds/pence split works accurately. +// 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); +// This takes everything except the last two digits +// The last two digits represent the pence, so whatever is left over fro the calculation is the pounds. + From 837e3efd0942cb691928c4e73c8724d40dfb602b Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 14:28:52 +0000 Subject: [PATCH 38/40] Committing the explanation of the program as step 5 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index cf557461f..23e225816 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -38,3 +38,7 @@ console.log(`£${pounds}.${pence}`); // This takes everything except the last two digits // The last two digits represent the pence, so whatever is left over fro the calculation is the pounds. +// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); +// The substring(paddedPenceNumberString.length - 2) takes the last two characters as the pence part "399" and converts it into "99" +// The .padEnd(2, "0") ensures the pence part is always 2 digits by adding trailing zeros if needed. +// In most cases there are already two digits, however part of the code protects against edge cases such as "3" becoming "30" which would be an inaccurate outcome. From 3ea132c3e93590fdc36cd6e901405c787e8431d4 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 14:31:29 +0000 Subject: [PATCH 39/40] Committing the explanation of the program as step 6 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 23e225816..65850068d 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -42,3 +42,6 @@ console.log(`£${pounds}.${pence}`); // The substring(paddedPenceNumberString.length - 2) takes the last two characters as the pence part "399" and converts it into "99" // The .padEnd(2, "0") ensures the pence part is always 2 digits by adding trailing zeros if needed. // In most cases there are already two digits, however part of the code protects against edge cases such as "3" becoming "30" which would be an inaccurate outcome. + +// 6. console.log(`£${pounds}.${pence}`); +// Prints the final formatted price in pounds and pence. An example would be "399p" would print as "£3.99 \ No newline at end of file From 599ea5273e9c55774611f40cbf9582e36dd9bb23 Mon Sep 17 00:00:00 2001 From: KayanatSuleman Date: Mon, 9 Feb 2026 14:43:09 +0000 Subject: [PATCH 40/40] correcting typos and making the explanation clearer --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 65850068d..214cbf234 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -28,7 +28,7 @@ console.log(`£${pounds}.${pence}`); // 2. const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1); // penceString.length -1: points to the index just before the last character. The substring(0, ect) takes everything from the start up to the last character (but not including the last character) -// The result removes th trailing "p" so the output becomes "399p" --> "399" +// The result removes the trailing "p" so the output becomes "399p" --> "399" // 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");: // Ensures the pence int has at least 3 characters by adding leading zeros if required. @@ -36,12 +36,12 @@ console.log(`£${pounds}.${pence}`); // 4. const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); // This takes everything except the last two digits -// The last two digits represent the pence, so whatever is left over fro the calculation is the pounds. +// The last two digits represent the pence, so whatever is left over from the calculation is the pounds. // 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); -// The substring(paddedPenceNumberString.length - 2) takes the last two characters as the pence part "399" and converts it into "99" +// The substring(paddedPenceNumberString.length - 2) takes the last two characters of the padded string (e.g. "399") and extacts the pence portion "99" // The .padEnd(2, "0") ensures the pence part is always 2 digits by adding trailing zeros if needed. -// In most cases there are already two digits, however part of the code protects against edge cases such as "3" becoming "30" which would be an inaccurate outcome. +// In most cases there are already two digits, however part of the code protects against outputs such as "3" becoming "30" which would be an inaccurate outcome. // 6. console.log(`£${pounds}.${pence}`); // Prints the final formatted price in pounds and pence. An example would be "399p" would print as "£3.99 \ No newline at end of file