From eac1a1b28640c128f0b9ee8c75ca5669b028faf6 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 00:25:09 +0000 Subject: [PATCH 01/28] declaraing the variable 'result' in capitalise function Corrected variable declaration issue and updated function to return the capitalized string. --- 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 653d6f5a07..39666b0606 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) { + let result = `${str[0].toUpperCase()}${str.slice(1)}`; + return resault; +} From 0a7da4355f5fd29ef9573abeda76c11ff58447a3 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 00:31:19 +0000 Subject: [PATCH 02/28] Fix duplicate variable declaration and assigning in convertToPercentage function Removed duplicate declaration of decimalNumber and updated the function to correctly convert a decimal to a percentage. --- 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 f2d56151f4..cb2870c5f3 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 45b6a430e22c2472474d6a1f37f9fe37c8a39ada Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 00:33:53 +0000 Subject: [PATCH 03/28] Fix square function parameter Corrected the square function to accept a parameter and return its square. --- Sprint-2/1-key-errors/2.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..a0873b5f1f 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -3,18 +3,20 @@ // 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 b594c90843d1731c2261ffeeaa5153fc7aa3747d Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 15:01:06 +0000 Subject: [PATCH 04/28] Fix multiply function to return and log result Refactor multiply function to return result and log output. --- 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 b27511b417..bd32b29c01 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 7fbd07f259753c79c0b60035923fa848c1ad292e Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 15:06:34 +0000 Subject: [PATCH 05/28] Fix sum function to return correct value Corrected the sum function to return the sum of two numbers. --- Sprint-2/2-mandatory-debug/1.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..90c8f9c1e5 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,12 @@ 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 54e11ce886c6cdcd842bc6205e54b4134d342c37 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 15:16:51 +0000 Subject: [PATCH 06/28] Fix getLastDigit function to return correct last digit Corrected the getLastDigit function to accept a parameter and return the last digit of the given 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 57d3f5dc35..9e0d7acd09 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 97bdb37da7684ffabc56e5c7560ac1204ac8135b Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 22:15:38 +0000 Subject: [PATCH 07/28] Fixing typo Corrected the function getLastDigit to properly accept a parameter. --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 9e0d7acd09..e454451407 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -24,7 +24,7 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // =============> 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 +function getLastDigit(num) { // we add the identifier num as parameter to the function getLastDigit return num.toString().slice(-1); } From 9dfa312f92c77e9dcc09fddda63873602857b670 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 28 Feb 2026 23:21:00 +0000 Subject: [PATCH 08/28] Implement BMI calculation in calculateBMI function --- Sprint-2/3-mandatory-implement/1-bmi.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1b..74ffb1dc01 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,5 +15,6 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height -} \ No newline at end of file + return BMI = (weight / (height * height)).toFixed(1); // return the BMI of someone based off their weight and height +} +console.log(calculateBMI(90, 1.77)); // when calling this function with given someone's weight and height From 5fb3b93070730ce0c9eb358965e431798eb4ac48 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 19:09:04 +0000 Subject: [PATCH 09/28] Update comments with answers in time-format.js Added explanations and answers to questions regarding the pad function in time-format.js. --- Sprint-2/4-mandatory-interpret/time-format.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 7c98eb0e8c..bf8c94ba29 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -18,17 +18,27 @@ function formatTimeDisplay(seconds) { // 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 b74597626f79c4c4c93ec2566be9f8b450d08a53 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:17:13 +0000 Subject: [PATCH 10/28] turn the to-pounds program into a reusable block of code Implemented the toPounds function to convert pence to pounds. --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a703..57834945c8 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,17 @@ // 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 6dcd3adcb1e321b659cb3439e4cef564be709945 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sun, 1 Mar 2026 22:21:17 +0000 Subject: [PATCH 11/28] 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 5b0ef77ad9..994aa4b5d3 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 98c6c440e9874866e29d90f19240ffb50938a3af Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:06:25 +0000 Subject: [PATCH 12/28] formatting using prettier --- Sprint-2/1-key-errors/0.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 39666b0606..ee5c6d5c5f 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -9,9 +9,9 @@ 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 +// =============> 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: +// =============> my new code: function capitalise(str) { let result = `${str[0].toUpperCase()}${str.slice(1)}`; return resault; From 49c0e77a0d2c9846982a73861b3d3de8a3289cbc Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:07:09 +0000 Subject: [PATCH 13/28] formatting using prettier --- Sprint-2/1-key-errors/1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index cb2870c5f3..d842a46ef3 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -18,9 +18,9 @@ console.log(decimalNumber); // =============> Identifier 'decimalNumber' has already been declared is the error msg thrown by the code // Finally, correct the code to fix the problem -// =============> +// =============> function convertToPercentage(decimalNumber) { -// const decimalNumber = 0.5; this line must be deleted + // const decimalNumber = 0.5; this line must be deleted const percentage = `${decimalNumber * 100}%`; return percentage; From f46495ada96cca60a5731eb656cc60a8ccc8c045 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:08:00 +0000 Subject: [PATCH 14/28] formatting using prettier --- Sprint-2/1-key-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index a0873b5f1f..ebf9ca54c2 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -19,4 +19,4 @@ function square(3) { function square(num) { return num * num; } -console.log(square(3)); +console.log(square(3)); \ No newline at end of file From 3a4cd9c744c1d3200ba94a442d99084096efb1bf Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:08:47 +0000 Subject: [PATCH 15/28] formatting using prettier --- Sprint-2/2-mandatory-debug/0.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index bd32b29c01..074efb5866 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -11,16 +11,18 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> the function multiply has no return statement // Finally, correct the code to fix the problem -// =============> +// =============> function multiply(a, b) { - return (a * b); // we change the console.log statement with the return statement + 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 +// 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)); + return console.log( + `The result of multiplying ` + a + ` and ` + b + ` is ` + a * b + ); } multiply(10, 32); From 0187c34954add9395caef4440714560b3fb91e87 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:14:24 +0000 Subject: [PATCH 16/28] formatting using prettier --- Sprint-2/2-mandatory-debug/2.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index e454451407..9c483c7d54 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -1,7 +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 @@ -24,7 +24,8 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // =============> 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 identifier num as parameter to the function getLastDigit +function getLastDigit(num) { + // we add the identifier num as parameter to the function getLastDigit return num.toString().slice(-1); } From d824908be38f0f97480ce1d888e3d6f1a614c699 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:16:43 +0000 Subject: [PATCH 17/28] formatting using prettier --- Sprint-2/2-mandatory-debug/0.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 074efb5866..322a078730 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -26,3 +26,4 @@ function multiply(a, b) { ); } multiply(10, 32); +// From e3e2a6e1f67202cc9b36190990f6ab1f2436cab8 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:17:00 +0000 Subject: [PATCH 18/28] formatting using prettier --- Sprint-2/2-mandatory-debug/0.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 322a078730..074efb5866 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -26,4 +26,3 @@ function multiply(a, b) { ); } multiply(10, 32); -// From d979e4730f983e3d7ec1d4b5ffeb25c4ec1c05b6 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:17:58 +0000 Subject: [PATCH 19/28] formatting using prettier --- Sprint-2/2-mandatory-debug/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 90c8f9c1e5..53368604ca 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -15,5 +15,5 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); function sum(a, b) { return a + b; } - +// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); From 074eddbebdfc33ca2735c219f892739e3747f290 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:18:08 +0000 Subject: [PATCH 20/28] formatting using prettier --- Sprint-2/2-mandatory-debug/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 53368604ca..90c8f9c1e5 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -15,5 +15,5 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); function sum(a, b) { return a + b; } -// + console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); From 614b5fc275720854aad0d371ee734692cc6246e2 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:20:37 +0000 Subject: [PATCH 21/28] formatting using prettier --- Sprint-2/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 9c483c7d54..7978fc8ebf 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -11,7 +11,7 @@ const num = 103; 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)}`); From 4e87db62f6b561001732121e7fc28f8497aa3258 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:21:30 +0000 Subject: [PATCH 22/28] formatting using prettier --- Sprint-2/2-mandatory-debug/2.js | 2 +- Sprint-2/3-mandatory-implement/1-bmi.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 7978fc8ebf..9c483c7d54 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -11,7 +11,7 @@ const num = 103; 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)}`); diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 74ffb1dc01..6c672e9645 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -3,7 +3,7 @@ // The BMI calculation divides an adult's weight in kilograms (kg) by their height in metres (m) squared. // For example, if you weigh 70kg (around 11 stone) and are 1.73m (around 5 feet 8 inches) tall, you work out your BMI by: - +// // squaring your height: 1.73 x 1.73 = 2.99 // dividing 70 by 2.99 = 23.41 // Your result will be displayed to 1 decimal place, for example 23.4. @@ -15,6 +15,6 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return BMI = (weight / (height * height)).toFixed(1); // return the BMI of someone based off their weight and height + return (BMI = (weight / (height * height)).toFixed(1)); // return the BMI of someone based off their weight and height } console.log(calculateBMI(90, 1.77)); // when calling this function with given someone's weight and height From ecbbbef7a71079fdfaf0aa0f534b9ab0a391f5a4 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:22:42 +0000 Subject: [PATCH 23/28] formatting using prettier --- Sprint-2/3-mandatory-implement/2-cases.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 994aa4b5d3..845d80b809 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -15,8 +15,8 @@ // 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 wsSnakeCase = wordsSet.replaceAll(" ", "_"); let wsupperSnakeCase = wsSnakeCase.toUpperCase(); return console.log(wsupperSnakeCase); } -upperSnakeCase('i do not know'); // evaluates to: "I_DO_NOT_KNOW" +upperSnakeCase("i do not know"); // evaluates to: "I_DO_NOT_KNOW" From 69ae220b1e666c3f767aa3fcd1a6c80955a97bb0 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Sat, 7 Mar 2026 19:23:24 +0000 Subject: [PATCH 24/28] formatting using prettier --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 57834945c8..a17621653d 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -6,15 +6,22 @@ // 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 penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1); + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 + ); -const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); -const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); + const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); -const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); - -return console.log(`£${pounds}.${pence}`); + return console.log(`£${pounds}.${pence}`); } -toPounds('399p') // £3.99 -toPounds('1095p') // £10.95 +toPounds("399p"); // £3.99 +toPounds("1095p"); // £10.95 From 0f84719684ad77b2dfbcc1b6bb36dcb72593f80c Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 12 Mar 2026 01:07:25 +0000 Subject: [PATCH 25/28] deleted the console.log statement from the function and added a return statement --- Sprint-2/2-mandatory-debug/0.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index 074efb5866..44f3ab69d0 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -9,7 +9,7 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> the function multiply has no return statement - +// when we call the function multiply(10, 32) it will throw this message: The result of multiplying 10 and 32 is undefined // Finally, correct the code to fix the problem // =============> function multiply(a, b) { @@ -17,12 +17,3 @@ function multiply(a, b) { } 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 3adc57d332e7c08e6dfa5a876dbed361f5c285aa Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 12 Mar 2026 01:39:33 +0000 Subject: [PATCH 26/28] fixed the statement of the value returned & converted the output to a number --- Sprint-2/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 6c672e9645..f3aed7592f 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,6 +15,6 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return (BMI = (weight / (height * height)).toFixed(1)); // return the BMI of someone based off their weight and height + return Number(weight / (height * height)).toFixed(1); // return the BMI of someone based off their weight and height } console.log(calculateBMI(90, 1.77)); // when calling this function with given someone's weight and height From 1393ad59420e4bf49f37d2948757a59d432f2fb2 Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 12 Mar 2026 01:52:46 +0000 Subject: [PATCH 27/28] fixed the function to return the coverted value --- Sprint-2/3-mandatory-implement/2-cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 845d80b809..570e7bdf71 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -17,6 +17,6 @@ function upperSnakeCase(wordsSet) { let wsSnakeCase = wordsSet.replaceAll(" ", "_"); let wsupperSnakeCase = wsSnakeCase.toUpperCase(); - return console.log(wsupperSnakeCase); + return wsupperSnakeCase; } upperSnakeCase("i do not know"); // evaluates to: "I_DO_NOT_KNOW" From 132b50e91a5a69e7a055c3eae582400471a364bd Mon Sep 17 00:00:00 2001 From: boladjebsoft Date: Thu, 12 Mar 2026 03:21:35 +0000 Subject: [PATCH 28/28] Fix return statement in calculateBMI function --- Sprint-2/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index f3aed7592f..60b08f5c2c 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,6 +15,6 @@ // It should return their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - return Number(weight / (height * height)).toFixed(1); // return the BMI of someone based off their weight and height + return Number((weight / (height * height)).toFixed(1)); // return the BMI of someone based off their weight and height } console.log(calculateBMI(90, 1.77)); // when calling this function with given someone's weight and height