From d20c0a3eaaf516a4dfebc330b778e3ebbed5d2be Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Mon, 23 Feb 2026 22:23:56 +0000 Subject: [PATCH 01/30] describing what line 3 is doing (reassignment) Updated comment to clarify the assignment operation. --- Sprint-1/1-key-exercises/1-count.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..7d4d50fe8 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -3,4 +3,4 @@ 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 +// the third line used the the assignment operator '=' to reassign the variable count to the initial value which is zero incremented by one resulting to the value 1 From 3428f4199b5a0b2de0dbed37f5838cec30142b28 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Tue, 24 Feb 2026 23:21:05 +0000 Subject: [PATCH 02/30] producing the string "CKJ" Updated the initials variable to dynamically generate initials from first, middle, and last names. --- 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 47561f617..000e8e1cc 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,11 @@ 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.charAt(0)+middleName.charAt(0)+lastName.charAt(0); +// or +let initials = firstName[0] + middleName[0] + lastName[0]; +// or but rarely used and not recommended because it might cause bugs +let initials = firstName[0].concat(middleName[0], lastName[0]); // https://www.google.com/search?q=get+first+character+of+string+mdn From 38427c240c47592e6dd708a07d115abc986f73d1 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 15:39:07 +0000 Subject: [PATCH 03/30] creating variable to store specific part (slice) of string Implemented logic to extract directory and extension from filePath. --- Sprint-1/1-key-exercises/3-paths.js | 9 ++++++--- 1 file changed, 6 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..6d1c509e5 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+1); +const ext = filePath.slice(-3); //the extention of the file is always the last three characters in the path +//or +const lastPointIndex = filePath.lastIndexOf("."); +const ext = filePath.slice(lastPointIndex+1); -// https://www.google.com/search?q=slice+mdn \ No newline at end of file +// https://www.google.com/search?q=slice+mdn From 2f3f08d109929057e3b48615d9a6f22a994b4736 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 18:52:47 +0000 Subject: [PATCH 04/30] building an idea of what a program is doing Added comments to explain the purpose and behavior of the num variable and the random number generation process. --- Sprint-1/1-key-exercises/4-random.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..74b490d15 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,14 @@ 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 + +// the num represents a value with limited interval and that's why +// the num assigned to a value that's in the dor of an expression +// the math object is invoked to perform some mathematical tasks +// the random method is invoked to get a random number between 0 and 1 +// the random number is multiplied by 100 +// the floor method is invoked to round down the result to its nearest integer +// added one to the new result +// the final result of the whole expression is what the variable num assigned to +/* after applying the program several times, I got the idea that the program is generating +a value to the num variable thats always between minimum an maximum*/ From 44271ba7b060f6ef262c88fae0a083fd97ae2547 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 22:06:55 +0000 Subject: [PATCH 05/30] Convert instructions to comments --- Sprint-1/2-mandatory-errors/0.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..59cd85d52 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,3 @@ -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? +// to make the computer not running these two line we use inline comments by adding two slashes at the beginning of each line From e0b32562ca045b8cad9c27ee6239553cd30703ac Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 22:12:34 +0000 Subject: [PATCH 06/30] Use 'let' for age variable to enable reassignment Changed 'const' to 'let' for age variable to allow reassignment. --- 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..af5aad5c0 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; // we should use the keyword 'let' to declare the variable 'age' to allow reassignment later age = age + 1; From 21914bb407a895b19e2de778edb292aead6b1778 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 22:18:35 +0000 Subject: [PATCH 07/30] Correct variable declaration for cityOfBirth Fix variable declaration order to avoid reference error. --- Sprint-1/2-mandatory-errors/2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..6fd12745c 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,7 @@ // 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}`); + +// the error is that the variable 'cityOfBirth' is declared after the statement it is used in From 17d93a63af0f07a5d89b1bbf927a826064e30249 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 22:51:54 +0000 Subject: [PATCH 08/30] Fix the typeOf variable to be able to use a method Updated last4Digits assignment to convert cardNumber to a string before slicing. --- Sprint-1/2-mandatory-errors/3.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..91263c6a0 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 last4Digits = (cardNumber.toString()).slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +7,12 @@ 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 + +/* my prediction about why the code isn't working is because either the new variable is declared with const keyword +or the value of the variable cardNumber is a number not a string whereas the method .slice works only with strings */ +// the error it gives 'cardNumber.slice is not a function' +// It gives this error because the computer assumes the coder is trying to invoke a function +// yes it is my second prediction +// updating the expression last4Digits is assigned to, in order to get the correct value is as follows +// method one: puting the value of the variable cardNumber into quotes +// method two: invoking the method .toString() to convert the type of the variable from number to string From af481768bb66e3740dd8941427761eaa0a7985d8 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Wed, 25 Feb 2026 23:02:00 +0000 Subject: [PATCH 09/30] Rename clock time variables to valid identifiers Updated variable names to avoid starting with digits. --- Sprint-1/2-mandatory-errors/4.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..d78326fc3 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,6 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const _12HourClockTime = "20:53"; // identifier can not begin with a number +// or +const $12HourClockTime = "20:53"; // or any change that makes the identifier not stating with digit +const _24hourClockTime = "08:53"; // identifier can not begin with a number +// or +const $24hourClockTime = "08:53"; // or any change that makes the identifier not stating with digit From 4ba270e254bce4b12a7dd8353cbb0035d7c89b4a Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 26 Feb 2026 23:15:14 +0000 Subject: [PATCH 10/30] Fix syntax error in priceAfterOneYear assignment Fixed syntax error in priceAfterOneYear assignment and updated comments. --- .../3-mandatory-interpret/1-percentage-change.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..73b30a9ea 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; @@ -12,11 +12,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 five function calls in this file, the lines where a call function is made are as follows: +// line 4, replaceAll() +// line 4, Number() +// line 5, replaceAll() +// line 5, 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? +// the error is coming from line 5 +// it is a syntax error, the expression priceAfterOneYear.replaceAll("," "") ismissing a comma +// to fix this problem we add comma between the two arguments // c) Identify all the lines that are variable reassignment statements +// the lines that are variable reassignment statements: -line 4 -line 5 // d) Identify all the lines that are variable declarations +// the lines that are variable declarations: -line 1 -line 2 -line 7 -line 8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// the expression calls the replace method to replace the comma with empty string +// converting the new string to a number to be able to perform math operations From 67c8968cf8c1f491eede4492285bd36d185a0ad0 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 26 Feb 2026 23:56:42 +0000 Subject: [PATCH 11/30] generating time format for duration of a movie --- 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..e2dcfae0c 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,21 @@ 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 declaration // b) How many function calls are there? +// there is one function call (console.log()) // c) Using documentation, explain what the expression movieLength % 60 represents +// it represents the remaining of dividing movielength by 60 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// it means the integer quotient of dividing movieLength by 60 // e) What do you think the variable result represents? Can you think of a better name for this variable? +// it represents the length of the movie in hours, minutes and seconds format +// a better name would be: movieTimeVolume // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// no it will not work for negative input values as it gives negative results From b72751f496440c69e9275a957d26afe2af82de00 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 15:22:01 +0000 Subject: [PATCH 12/30] describing the purpose behind each step of the code Added comments to explain the purpose of each step in the code. --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 5 +++++ 1 file changed, 5 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..ddb4b40a4 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,8 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// line 3: calling substring method to remove the 'p' letter and keep only digits in the string +// line 8: using padstart method to make the minimum length of the string to 3 characters by adding one zero or two to the left. +// line 9: using substring method to take only the integer part +// line 14: using substring method to take only the decimal part and padend method to make the minimum length of pence to 2 characters by adding zero to the right +// line 18: calling console function to print the integer part that represents the pound and the decimal part that represents the pence seprated by point From 35fdc82b33b2cd71659161ad72ece8c01e54cf55 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 22:34:27 +0000 Subject: [PATCH 13/30] Fix variable redeclaration in a function Updated the capitalise function to fix variable redeclaration and corrected the return variable name. --- Sprint-2/1-key-errors/0.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a0..26eec1a58 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> the function is not going to work because a variable is declared twice (str) // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -9,5 +9,10 @@ function capitalise(str) { return str; } -// =============> write your explanation here -// =============> write your new code here +// =============> the error message 'Identifier 'str' has already been declared', diplays because the toUpperCase function does not change the value of the varible declared +// but it creates a new one. +// =============> my new code: +function capitalise(str) { + result = `${str[0].toUpperCase()}${str.slice(1)}`; + return resault; +} From 4fdfb0707d0ae38a1cef926a9668fff91f466c47 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 22:38:27 +0000 Subject: [PATCH 14/30] declaraing the variable 'result' in capitalise function Declare 'result' with 'let' to avoid redeclaration error. --- Sprint-2/1-key-errors/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 26eec1a58..39666b060 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -13,6 +13,6 @@ function capitalise(str) { // but it creates a new one. // =============> my new code: function capitalise(str) { - result = `${str[0].toUpperCase()}${str.slice(1)}`; + let result = `${str[0].toUpperCase()}${str.slice(1)}`; return resault; } From d100737073f2f48036d5eccaf331b3e7321c218c Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 22:51:51 +0000 Subject: [PATCH 15/30] Fix duplicate variable declaration and assigning in convertToPercentage function Removed duplicate declaration of decimalNumber and updated comments. --- Sprint-2/1-key-errors/1.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f..cb2870c5f 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,7 +1,8 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> because first: the variable decimalNumber is declared twice +// second: the parameter decimalNumber is assigned to a value inside the function // Try playing computer with the example to work out what is going on @@ -14,7 +15,13 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> write your explanation here +// =============> Identifier 'decimalNumber' has already been declared is the error msg thrown by the code // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> +function convertToPercentage(decimalNumber) { +// const decimalNumber = 0.5; this line must be deleted + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} From 3bcd5ba7f028cd57a445df6af8e4684f3b778d73 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 23:02:42 +0000 Subject: [PATCH 16/30] Fix square function parameter Corrected the square function to properly accept a parameter and return its square. --- Sprint-2/1-key-errors/2.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cf..25eb01a12 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -3,18 +3,22 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> identifier not declared (unknown) function square(3) { return num * num; } -// =============> write the error message here +// =============> Unexpected number -// =============> explain this error message here +// =============> the parameter shouldn't be given an argument in the function definition // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> my new code +function square(num) { + return num * num; +} +console.log(square(3)); From 5809aeec54cfeae9d2cd763b7f590d7566076987 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 23:48:00 +0000 Subject: [PATCH 17/30] Fix multiply function to return result and log output Refactored multiply function to include return statement and improved logging. --- Sprint-2/2-mandatory-debug/0.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b41..bd32b29c0 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,6 +1,6 @@ // Predict and explain first... -// =============> write your prediction here +// =============> the function when called will throw an error function multiply(a, b) { console.log(a * b); @@ -8,7 +8,19 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> the function multiply has no return statement // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> +function multiply(a, b) { + return (a * b); // we change the console.log statement with the return statement +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); + +// an extra notice: the purpose of creating a function is to reuse it when needed +// I've noticed that the parameters are already assigned to values 10 and 32, so I changed the code to the following: +function multiply(a, b) { + return console.log(`The result of multiplying ` + a +` and ` + b +` is ` + (a * b)); +} +multiply(10, 32); From eee4034ac0c72706dce804eb8d88fe59323e5184 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Fri, 27 Feb 2026 23:56:06 +0000 Subject: [PATCH 18/30] Correct sum function to return the sum of arguments Fix the sum function to correctly return the sum of two numbers. --- Sprint-2/2-mandatory-debug/1.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcf..25d013be0 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> The sum of 10 and 32 is undefined function sum(a, b) { return; @@ -8,6 +8,13 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> the function sum returns Nul because it's straight followed by semicolon thate ends the statement +// also the statement a + b is in new line // Finally, correct the code to fix the problem -// =============> write your new code here +// =============> my new code +function sum(a, b) { + return a + b; +} + +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); + From db4474820eeca48ceda366735b43fe8e12ee1a04 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 00:09:47 +0000 Subject: [PATCH 19/30] Fix getLastDigit function to return correct last digit Corrected the getLastDigit function to accept a parameter and return the last digit of a number. --- Sprint-2/2-mandatory-debug/2.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc3..9e0d7acd0 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,7 +1,10 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> +// The last digit of 42 is 3 +// The last digit of 105 is 3 +// The last digit of 806 is 3 const num = 103; @@ -14,11 +17,20 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction -// =============> write the output here +// =============>// The last digit of 42 is 3 +// The last digit of 105 is 3 +// The last digit of 806 is 3 // Explain why the output is the way it is -// =============> write your explanation here +// =============> the variable num is assigned to the value 103 in the global scope and not assigned to any value in the function scope // Finally, correct the code to fix the problem // =============> write your new code here +function getLastDigit(num) { // we add the identier num as parameter to the function getLastDigit + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 429f649a39b387f39e43da77bc74e7ba9d5c668b Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 15:57:19 +0000 Subject: [PATCH 20/30] Implement upperSnakeCase function Added a function to convert a string to upper snake case. --- Sprint-2/3-mandatory-implement/2-cases.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad..994aa4b5d 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,9 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase +function upperSnakeCase(wordsSet) { + let wsSnakeCase = wordsSet.replaceAll(' ','_'); + let wsupperSnakeCase = wsSnakeCase.toUpperCase(); + return console.log(wsupperSnakeCase); +} +upperSnakeCase('i do not know'); // evaluates to: "I_DO_NOT_KNOW" From 92bd8ef8afa349e4cb4d0c99b88c687bd8a840b7 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 16:09:22 +0000 Subject: [PATCH 21/30] Implement toPounds function --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a70..656792454 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,16 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs +function toPounds(penceString) { + +const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1); + +const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); + +const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); + +return console.log(`£${pounds}.${pence}`); +} +toPounds('399p') // £3.99 +toPounds('1095p') // £10.95 From 56b74d5f822563c2bf7600d712a49a7ecc154b99 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 19:02:33 +0000 Subject: [PATCH 22/30] Clarify pad function behavior in comments Updated comments in time-format.js to clarify the behavior of the pad function. --- Sprint-2/4-mandatory-interpret/time-format.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8..a5facbec8 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -17,18 +17,27 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> pad will be called 3 times // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> the value assigned to num is 0 // c) What is the return value of pad is called for the first time? -// =============> write your answer here +// =============> the return value of pad is called for the first time is "00" // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> the value assigned to num is 1 +// because the last time pad is called for the remainingSeconds holding the value 1 +// return pad(remainingSeconds) +// function pad(1){ // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> the return value of pad is called for the last time is "01" +// because the argument passed to the pad parameter is the value of the remainingSeconds wich is 1 +// function pad(1){ +// return 1.toString().padStart(2, "0"); +// return "1".pad(2,"0"); +// return "01" +//} From 5196c63e432fb64607e334dd9dfcedff1d734275 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 19:08:29 +0000 Subject: [PATCH 23/30] Clean up comments in time-format.js Removed comments with answers to questions about the pad function. --- Sprint-2/4-mandatory-interpret/time-format.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index a5facbec8..f24c426fb 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -17,27 +17,18 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> pad will be called 3 times + // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> the value assigned to num is 0 +// =============> write your answer here // c) What is the return value of pad is called for the first time? -// =============> the return value of pad is called for the first time is "00" +// =============> write your answer here // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> the value assigned to num is 1 -// because the last time pad is called for the remainingSeconds holding the value 1 -// return pad(remainingSeconds) -// function pad(1){ +// =============> write your answer here // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> the return value of pad is called for the last time is "01" -// because the argument passed to the pad parameter is the value of the remainingSeconds wich is 1 -// function pad(1){ -// return 1.toString().padStart(2, "0"); -// return "1".pad(2,"0"); -// return "01" -//} +// =============> write your answer here From 122c731ad28403032be415e96b875edccfb0640f Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:15:01 +0000 Subject: [PATCH 24/30] Refactor toPounds function Refactor toPounds function for reusability and clarity. --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 656792454..6265a1a70 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,16 +4,3 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs -function toPounds(penceString) { - -const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1); - -const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); -const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); - -const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); - -return console.log(`£${pounds}.${pence}`); -} -toPounds('399p') // £3.99 -toPounds('1095p') // £10.95 From 7d09f40e315ffe84147e63ce9dc0f5ba7cba979e Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:20:30 +0000 Subject: [PATCH 25/30] Remove upperSnakeCase function restore the file to the main version Removed the upperSnakeCase function implementation and example call. --- Sprint-2/3-mandatory-implement/2-cases.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 994aa4b5d..5b0ef77ad 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,9 +14,3 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase -function upperSnakeCase(wordsSet) { - let wsSnakeCase = wordsSet.replaceAll(' ','_'); - let wsupperSnakeCase = wsSnakeCase.toUpperCase(); - return console.log(wsupperSnakeCase); -} -upperSnakeCase('i do not know'); // evaluates to: "I_DO_NOT_KNOW" From 7b87fbc5bbd98c0be4b11fc25882e06c08f409be Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:27:55 +0000 Subject: [PATCH 26/30] Update 2.js --- Sprint-2/2-mandatory-debug/2.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 9e0d7acd0..57d3f5dc3 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,10 +1,7 @@ // Predict and explain first... // Predict the output of the following code: -// =============> -// The last digit of 42 is 3 -// The last digit of 105 is 3 -// The last digit of 806 is 3 +// =============> Write your prediction here const num = 103; @@ -17,20 +14,11 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction -// =============>// The last digit of 42 is 3 -// The last digit of 105 is 3 -// The last digit of 806 is 3 +// =============> write the output here // Explain why the output is the way it is -// =============> the variable num is assigned to the value 103 in the global scope and not assigned to any value in the function scope +// =============> write your explanation here // Finally, correct the code to fix the problem // =============> write your new code here -function getLastDigit(num) { // we add the identier num as parameter to the function getLastDigit - return num.toString().slice(-1); -} - -console.log(`The last digit of 42 is ${getLastDigit(42)}`); -console.log(`The last digit of 105 is ${getLastDigit(105)}`); -console.log(`The last digit of 806 is ${getLastDigit(806)}`); // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 652dbc11025329259f780f3b067730a066456263 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:31:23 +0000 Subject: [PATCH 27/30] Update 1.js Fix the sum function to return the correct result. --- Sprint-2/2-mandatory-debug/1.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 25d013be0..37cedfbcf 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> The sum of 10 and 32 is undefined +// =============> write your prediction here function sum(a, b) { return; @@ -8,13 +8,6 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> the function sum returns Nul because it's straight followed by semicolon thate ends the statement -// also the statement a + b is in new line +// =============> write your explanation here // Finally, correct the code to fix the problem -// =============> my new code -function sum(a, b) { - return a + b; -} - -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); - +// =============> write your new code here From bbdcc95453a99e5c11041e9dd0ad2580d9fc22ab Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:33:46 +0000 Subject: [PATCH 28/30] Update 2.js Corrected the square function to properly accept a parameter and return its square. --- Sprint-2/1-key-errors/2.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index 25eb01a12..09ecc0499 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -3,22 +3,16 @@ // this function should square any number but instead we're going to get an error -// =============> identifier not declared (unknown) +// =============> write your prediction of the error here function square(3) { return num * num; } -// =============> Unexpected number +// =============> write the error message here -// =============> the parameter shouldn't be given an argument in the function definition +// =============> explain this error message here // Finally, correct the code to fix the problem -// =============> my new code -function square(num) { - return num * num; -} -console.log(square(3)); - - +// =============> write your new code here From 177c3687417cddee17598ee568401742d626ac47 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:36:10 +0000 Subject: [PATCH 29/30] Update 1.js Updated comments to clarify errors and provide explanations. --- Sprint-2/1-key-errors/1.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index cb2870c5f..f2d56151f 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,8 +1,7 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> because first: the variable decimalNumber is declared twice -// second: the parameter decimalNumber is assigned to a value inside the function +// =============> write your prediction here // Try playing computer with the example to work out what is going on @@ -15,13 +14,7 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> Identifier 'decimalNumber' has already been declared is the error msg thrown by the code +// =============> write your explanation here // Finally, correct the code to fix the problem -// =============> -function convertToPercentage(decimalNumber) { -// const decimalNumber = 0.5; this line must be deleted - const percentage = `${decimalNumber * 100}%`; - - return percentage; -} +// =============> write your new code here From 3bb9ddf441cce7888063f86247f2cf6e8a9ba323 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:47:26 +0000 Subject: [PATCH 30/30] Update 0.js Removed duplicate variable declaration and fixed typo in return statement. --- Sprint-2/1-key-errors/0.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 39666b060..653d6f5a0 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> the function is not going to work because a variable is declared twice (str) +// =============> write your prediction here // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -9,10 +9,5 @@ function capitalise(str) { return str; } -// =============> the error message 'Identifier 'str' has already been declared', diplays because the toUpperCase function does not change the value of the varible declared -// but it creates a new one. -// =============> my new code: -function capitalise(str) { - let result = `${str[0].toUpperCase()}${str.slice(1)}`; - return resault; -} +// =============> write your explanation here +// =============> write your new code here