From 00fdc77596c9c1dd5ba2bd6b6074a70d22d0f729 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 00:13:15 +0100 Subject: [PATCH 01/23] solving exercise 0.js --- Sprint-3/1-key-errors/0.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..5ee1f384f 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,5 +1,6 @@ // Predict and explain first... // =============> write your prediction here +// Tha parameter 'str' is declared another time insie the function , this will cause an error to be thrown. // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -9,5 +10,10 @@ function capitalise(str) { return str; } -// =============> write your explanation here -// =============> write your new code here +// =============> write your explanation here SyntaxError: Identifier 'str' has already been declared => line 10 varibale str should not be declared again. +// =============> write your new code +// function capitalise(str) { +// str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } +// console.log(capitalise("hello world")); From 567077e849ad532b389b7b298204e54df06b1347 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 00:41:06 +0100 Subject: [PATCH 02/23] solving exercise 2.js --- Sprint-3/1-key-errors/2.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..64ca9e723 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,21 @@ - // Predict and explain first BEFORE you run any code... // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here - +// =============> write your prediction of the error here : The funcation parameter 3 this will cause an error to be thrown because the parameter is not a valid identifier. function square(3) { return num * num; + } -// =============> write the error message here +// =============> write the error message here: SyntaxError: Unexpected number -// =============> explain this error message here +// =============> explain this error message here: SyntaxError: Unexpected number , the parameter 3 is not a valid identifier it should ba valid identifier like num. // Finally, correct the code to fix the problem // =============> write your new code here - - +// function square(num) { +// return num * num; +// } +// console.log(square(3)); From c91ef999223e3ad93e855db4a7a8c59a2bf46b00 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 00:50:20 +0100 Subject: [PATCH 03/23] solving 0.js --- Sprint-3/2-mandatory-debug/0.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..9b00d1e7e 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,19 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here : The function multipy does not return any value so the result of calling the function will be unknown. -function multiply(a, b) { - console.log(a * b); -} +// function multiply(a, b) { +// console.log(a * b); +// } -console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); -// =============> write your explanation here +// =============> write your explanation here : Calling the function has logged the result in the console but it has not returned the result ot the multiplicaion so the second console.log outside the function has no value to print and has printed undefined. // Finally, correct the code to fix the problem // =============> write your new code here +// function multiply(a, b) { +// return a * b; +// } + +// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); From 0afe2a9de0a8f84d91fca7ebffa0c6880b62e7ce Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 15:13:47 +0100 Subject: [PATCH 04/23] solving exercise 2-mandatory-debug 1.js --- Sprint-3/2-mandatory-debug/1.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..ead98eb17 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// =============> write your prediction here: this code will give an error because the funcion does not return any value and calling it within the consle.log will print undefined. function sum(a, b) { return; @@ -8,6 +8,10 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// =============> write your explanation here : the sum a+b in line 6 should precede the return statement inorder to return the value. // Finally, correct the code to fix the problem // =============> write your new code here + +// function sum(a, b) { +// return a + b; +// } From 292e89910cb89715386fe1f599cf4ddeef1b0ca3 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 16:09:06 +0100 Subject: [PATCH 05/23] solving exercise 2-mandatory-debug 2.js --- Sprint-3/2-mandatory-debug/2.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..d6acf02d9 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,7 +1,7 @@ // Predict and explain first... // Predict the output of the following code: -// =============> Write your prediction here +// =============> Write your prediction here: This code will throw an error because the function getLastDigit does not take any parameters but we are passing a parameter to it in the console.log statements. const num = 103; @@ -14,11 +14,22 @@ 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 +// =============> write the output here :output +/* 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 +// =============> write your explanation here: The funtion return on single value (3) no matter what parameter is passed to it because the function does not take any parameters and it is using the gobal variable num which is set to 103. So the last digit of 103 is always 3. // Finally, correct the code to fix the problem // =============> write your new code here +// function getLastDigit(num) { +// 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 +// Explain why getLastDigit is not working properly - correct the problem : The first declaration of num as constent should be removed and the function getLastDigit should take a parameter num to return the last digit of the number passed to it. From c7c8f3a84d26d8e002a3b9cb205463657313bfba Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 16:18:09 +0100 Subject: [PATCH 06/23] solving exercise 3-mandatory-implement 1-bmi.js --- Sprint-3/3-mandatory-implement/1-bmi.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..23d06683d 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -16,4 +16,9 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height + return weight / (height * height); } + +console.log(calculateBMI(70, 1.73).toFixed(1)); // should return 23.4 + + From a239738502251e9c44806e900a021768b66461ce Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 16:42:27 +0100 Subject: [PATCH 07/23] solving the 2 3-mandatory-implements exercises --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 -- Sprint-3/3-mandatory-implement/2-cases.js | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 23d06683d..895086ce0 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -20,5 +20,3 @@ function calculateBMI(weight, height) { } console.log(calculateBMI(70, 1.73).toFixed(1)); // should return 23.4 - - diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..6382596b7 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,7 @@ // 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 toUpperSnakeCase(str) { + return str.toUpperCase().replaceAll(" ", "_"); +} +console.log(toUpperSnakeCase("lord of the rings")); From 63cc7a9633095243b053947df846be331b6fc663 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 22:11:27 +0100 Subject: [PATCH 08/23] solve exercise 3-t-pounds.js --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 10754da73..2d21f69b3 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,31 @@ // 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 `£${pounds}.${pence}`; +} + +console.log(toPounds("4798P")); +console.log(toPounds("31P")); +console.log(toPounds("0P")); +console.log(toPounds("-5576P")); +console.log(toPounds("4P")); +console.log(toPounds("832P")); +console.log(toPounds("200000P")); From c1fab78e61d929f4e409d03d58aac7685bd130b3 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 24 Sep 2026 22:59:32 +0100 Subject: [PATCH 09/23] Add time format functionality --- Sprint-3/4-mandatory-interpret/time-format.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..0d6568d64 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -3,6 +3,7 @@ function pad(num) { while (numString.length < 2) { numString = "0" + numString; } + console.log(numString); return numString; } @@ -15,24 +16,26 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } +console.log(formatTimeDisplay(61)); + // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> write your answer here: ***Answer*** :Function 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 +// b) What is the value assigned to num when pad is called for the first time?: +// =============> write your answer here: ***Answer*** : The value assigned to num =61. // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here +// =============> write your answer here: ***Answer*** :The value of pad when it 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 +// 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: ***Answer***: The last call of pad in this program is pad(remainingSeconds) => remainingSeconds= (61%60=1) => num = 1. // e) What is the return value of pad when it is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> write your answer here : ***Answer*** : The value of pad when is called for the last time is the third part in `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}` => pad(remainingSeconds)=pad(1) since 1 has a length <2 return will be padded with 0 => pad (1)return "01". From ca30eb550ffb731b43c4f7de774605a2029c4b64 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Fri, 25 Sep 2026 11:49:08 +0100 Subject: [PATCH 10/23] solving format-time --- Sprint-3/5-stretch-extend/format-time.js | 83 ++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..7680eed4a 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -4,22 +4,91 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; + const minutes = Number(time.slice(3, 5)); + + if (hours < 12) { + return `${time} am`; + } else if (hours == 12) { + return `${time} am`; + } else if (hours == 24) { + return `12:00 am`; + } + + if (hours > 12 && hours < 22 && minutes < 10) { + return `${(hours - 12).toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")} pm`; + } + if (hours > 12 && hours < 22 && minutes >=10) { + return `${(hours - 12).toString().padStart(2, "0")}:${minutes} pm`; + } + if (hours >= 22 && minutes < 10) { + return `${hours - 12}:${minutes.toString().padStart(2, "0")} pm`; + } + if (hours >= 22 && minutes >= 10) { + return `${hours - 12}:${minutes} pm`; } - return `${time} am`; } -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; +const currentOutput = formatAs12HourClock("01:00"); +const targetOutput = "01:00 am"; console.assert( currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` + `current output: ${currentOutput}, target output: ${targetOutput}`, ); const currentOutput2 = formatAs12HourClock("23:00"); const targetOutput2 = "11:00 pm"; console.assert( currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` + `current output: ${currentOutput2}, target output: ${targetOutput2}`, +); + +const currentOutput3 = formatAs12HourClock("00:00"); +const targetOutput3 = "00:00 am"; +console.assert( + currentOutput3 === targetOutput3, + `current output: ${currentOutput3}, target output: ${targetOutput3}`, +); + +const currentOutput4 = formatAs12HourClock("23:59"); // ***Asserrion failed : This needs fixing if hours > 12 minutes are not tracked and replaced by 00. =>fixec +// ); +const targetOutput4 = "11:59 pm"; +console.assert( + currentOutput4 === targetOutput4, + `current output: ${currentOutput4}, target output: ${targetOutput4}`, +); + +const currentOutput5 = formatAs12HourClock("12:00"); +const targetOutput5 = "12:00 am"; +console.assert( + currentOutput5 === targetOutput5, + `current output: ${currentOutput5}, target output: ${targetOutput5}`, // ***Asserrion failed : This needs fixing => fixed +); + +const currentOutput6 = formatAs12HourClock("24:00"); // ***Asserrion failed : This needs fixing =>fixed +const targetOutput6 = "12:00 am"; +console.assert( + currentOutput6 === targetOutput6, + `current output: ${currentOutput6}, target output: ${targetOutput6}`, +); + +const currentOutput7 = formatAs12HourClock("12:01"); // ***Asserrion failed : This needs fixing =>fixed +const targetOutput7 = "12:01 am"; +console.assert( + currentOutput7 === targetOutput7, + `current output: ${currentOutput7}, target output: ${targetOutput7}`, ); + +const currentOutput8 = formatAs12HourClock("22:10"); // ***Asserrion failed : This needs fixing =>fixed +const targetOutput8 = "01:10 am"; +console.assert( + currentOutput8=== targetOutput8, + `current output: ${currentOutput8}, target output: ${targetOutput8}`, +); + +const currentOutput9 = formatAs12HourClock("22:10"); // ***Asserrion failed : This needs fixing =>fixed +const targetOutput9 = "10:10 am"; +console.assert( + currentOutput9 === targetOutput9, + `current output: ${currentOutput9}, target output: ${targetOutput9}`, +); + From 142dcbdc10212b6fcfb66944499645cb32981f03 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 16:47:15 +0100 Subject: [PATCH 11/23] solving exercise 0.1 --- Sprint-3/1-key-errors/1.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..319fb7d86 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,12 +1,11 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> write your prediction here D: Answer => variable decimalNumber is declared twice : one time in the parameter and another time inside the function -// Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; + //const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; @@ -15,6 +14,15 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); // =============> write your explanation here - +// solution :Also in line 15 console.log is trying print a variable which is not defined instead of calling the function convertToPercentage . // Finally, correct the code to fix the problem // =============> write your new code here + + function convertToPercentage(decimalNumber) { + + const percentage = `${decimalNumber * 100}%`; + + return percentage; + } + + console.log(convertToPercentage(0.5)); From 5a1f1290f97cbd7b598d11aeb06f3d2f06c3d98b Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 16:52:10 +0100 Subject: [PATCH 12/23] uncommingting correct code to be able to run --- Sprint-3/1-key-errors/0.js | 18 +++++++++--------- Sprint-3/1-key-errors/1.js | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 5ee1f384f..829a775a0 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -5,15 +5,15 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; -} - -// =============> write your explanation here SyntaxError: Identifier 'str' has already been declared => line 10 varibale str should not be declared again. -// =============> write your new code // function capitalise(str) { -// str = `${str[0].toUpperCase()}${str.slice(1)}`; +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; // return str; // } -// console.log(capitalise("hello world")); + +// =============> write your explanation here SyntaxError: Identifier 'str' has already been declared => line 10 varibale str should not be declared again. +// =============> write your new code +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} +console.log(capitalise("hello world")); diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 319fb7d86..c970453a6 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -4,14 +4,14 @@ // =============> write your prediction here D: Answer => variable decimalNumber is declared twice : one time in the parameter and another time inside the function -function convertToPercentage(decimalNumber) { - //const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; +// function convertToPercentage(decimalNumber) { +// //const decimalNumber = 0.5; +// const percentage = `${decimalNumber * 100}%`; - return percentage; -} +// return percentage; +// } -console.log(decimalNumber); +// console.log(decimalNumber); // =============> write your explanation here // solution :Also in line 15 console.log is trying print a variable which is not defined instead of calling the function convertToPercentage . From f95f159ef36da88e9d64b115fc8ded499bd5dd19 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 16:54:24 +0100 Subject: [PATCH 13/23] fixing exercise 2.js --- Sprint-3/1-key-errors/2.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 64ca9e723..7c0011c55 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -3,10 +3,10 @@ // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here : The funcation parameter 3 this will cause an error to be thrown because the parameter is not a valid identifier. -function square(3) { - return num * num; +// function square(3) { +// return num * num; -} +// } // =============> write the error message here: SyntaxError: Unexpected number @@ -15,7 +15,7 @@ function square(3) { // Finally, correct the code to fix the problem // =============> write your new code here -// function square(num) { -// return num * num; -// } -// console.log(square(3)); +function square(num) { + return num * num; +} +console.log(square(3)); From f598953d8db6b645fbc585a14e34dc4716ffc177 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 16:56:38 +0100 Subject: [PATCH 14/23] fixing exercise 0.1 2-mandatory-debug --- Sprint-3/2-mandatory-debug/0.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 9b00d1e7e..c6a07e089 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -12,8 +12,8 @@ // Finally, correct the code to fix the problem // =============> write your new code here -// function multiply(a, b) { -// return a * b; -// } +function multiply(a, b) { + return a * b; +} -// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); From f4b5d6ac06e7e093339c8802c3309b9f17896aa4 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 17:14:35 +0100 Subject: [PATCH 15/23] fixing exercise 1-bmi.js --- Sprint-3/3-mandatory-implement/1-bmi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 895086ce0..8192eeeb7 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -16,7 +16,7 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height - return weight / (height * height); + return `${(weight / (height * height)).toFixed(1)}`; } -console.log(calculateBMI(70, 1.73).toFixed(1)); // should return 23.4 +console.log(calculateBMI(70, 1.73)); // should return 23.4 From cf05ff45d92535183623f79919b9e80b0c2d183f Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 17:29:25 +0100 Subject: [PATCH 16/23] removing unnecessary console.log in line 6 --- Sprint-3/4-mandatory-interpret/time-format.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 0d6568d64..8967f230d 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -3,7 +3,6 @@ function pad(num) { while (numString.length < 2) { numString = "0" + numString; } - console.log(numString); return numString; } From 7947510eef93c4c69f183516d4dc19ddb1b23187 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 21:50:33 +0100 Subject: [PATCH 17/23] uncomment solution for exercies 1.js --- Sprint-3/2-mandatory-debug/1.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index ead98eb17..73fe12be7 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,17 +1,18 @@ // Predict and explain first... // =============> write your prediction here: this code will give an error because the funcion does not return any value and calling it within the consle.log will print undefined. -function sum(a, b) { - return; - a + b; -} +// function sum(a, b) { +// return; +// a + b; +// } -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); +// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here : the sum a+b in line 6 should precede the return statement inorder to return the value. // Finally, correct the code to fix the problem // =============> write your new code here -// function sum(a, b) { -// return a + b; -// } +function sum(a, b) { + return a + b; +} +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); \ No newline at end of file From b503934cec91fc0c50c1e4fa584f8a51acfa8d3b Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 21:53:29 +0100 Subject: [PATCH 18/23] uncomment solution for exercies 2.js --- Sprint-3/2-mandatory-debug/2.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index d6acf02d9..7f989f218 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -5,13 +5,13 @@ const num = 103; -function getLastDigit() { - return num.toString().slice(-1); -} +// 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)}`); +// 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)}`); // Now run the code and compare the output to your prediction // =============> write the output here :output @@ -20,16 +20,16 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); The last digit of 806 is 3 */ // Explain why the output is the way it is -// =============> write your explanation here: The funtion return on single value (3) no matter what parameter is passed to it because the function does not take any parameters and it is using the gobal variable num which is set to 103. So the last digit of 103 is always 3. +// =============> write your explanation here: The funtion return one single value (3) no matter what parameter is passed to it because the function does not take any parameters and it is using the gobal variable num which is set to 103. So the last digit of 103 is always 3. // Finally, correct the code to fix the problem // =============> write your new code here -// function getLastDigit(num) { -// 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)}`); +function getLastDigit(num) { + 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 : The first declaration of num as constent should be removed and the function getLastDigit should take a parameter num to return the last digit of the number passed to it. From 92e313297f8422cc67361703335d79a06c020f1e Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 22:01:30 +0100 Subject: [PATCH 19/23] correct num value --- Sprint-3/4-mandatory-interpret/time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 8967f230d..77addc3fb 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -28,7 +28,7 @@ console.log(formatTimeDisplay(61)); // 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: ***Answer*** : The value assigned to num =61. +// =============> write your answer here: ***Answer*** : The value assigned to num =00. // c) What is the return value of pad when it is called for the first time? // =============> write your answer here: ***Answer*** :The value of pad when it is called for the first time is "00". From 514bece2f546bec0e9aa4af7fdddcc4a500828bb Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Tue, 29 Sep 2026 22:07:59 +0100 Subject: [PATCH 20/23] fix formatting to exercise 1.js --- Sprint-3/1-key-errors/1.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index c970453a6..55e37d951 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -3,26 +3,20 @@ // Why will an error occur when this program runs? // =============> write your prediction here D: Answer => variable decimalNumber is declared twice : one time in the parameter and another time inside the function - // function convertToPercentage(decimalNumber) { // //const decimalNumber = 0.5; // const percentage = `${decimalNumber * 100}%`; - // return percentage; // } // console.log(decimalNumber); - // =============> write your explanation here // solution :Also in line 15 console.log is trying print a variable which is not defined instead of calling the function convertToPercentage . // Finally, correct the code to fix the problem // =============> write your new code here - function convertToPercentage(decimalNumber) { - - const percentage = `${decimalNumber * 100}%`; - - return percentage; - } - - console.log(convertToPercentage(0.5)); +function convertToPercentage(decimalNumber) { + const percentage = `${decimalNumber * 100}%`; + return percentage; +} +console.log(convertToPercentage(0.5)); From 760800c2f099e56074d869afd4955d6950d9bbde Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 1 Oct 2026 05:32:14 +0100 Subject: [PATCH 21/23] removing unused variable --- Sprint-3/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 7f989f218..2d7b47a3e 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -3,7 +3,7 @@ // Predict the output of the following code: // =============> Write your prediction here: This code will throw an error because the function getLastDigit does not take any parameters but we are passing a parameter to it in the console.log statements. -const num = 103; +//const num = 103; // function getLastDigit() { // return num.toString().slice(-1); From a1cc998b7c99a694d21cb580ff47efe1f13e3527 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 1 Oct 2026 05:38:24 +0100 Subject: [PATCH 22/23] correct the answer for vlue assigned to num --- Sprint-3/4-mandatory-interpret/time-format.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index 77addc3fb..883b3863e 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,4 +1,5 @@ function pad(num) { + console.log(num) let numString = num.toString(); while (numString.length < 2) { numString = "0" + numString; @@ -28,7 +29,7 @@ console.log(formatTimeDisplay(61)); // 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: ***Answer*** : The value assigned to num =00. +// =============> write your answer here: ***Answer*** : The value assigned to num = 0. // c) What is the return value of pad when it is called for the first time? // =============> write your answer here: ***Answer*** :The value of pad when it is called for the first time is "00". From 5698bf5f42e5a7c9f10b06a978e07bbbce0b9bf6 Mon Sep 17 00:00:00 2001 From: Abdennour Hachemi Date: Thu, 1 Oct 2026 05:42:09 +0100 Subject: [PATCH 23/23] fix 1.js formmatting issue --- Sprint-3/2-mandatory-debug/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 73fe12be7..c2a9e03b6 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -15,4 +15,4 @@ function sum(a, b) { return a + b; } -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); \ No newline at end of file +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);