From f97b348a7a6a29dbea4e5e49d16ac79fa59dfabc Mon Sep 17 00:00:00 2001 From: Carol Date: Fri, 25 Sep 2026 19:03:50 +0100 Subject: [PATCH 1/4] updated files in key errors and mandatory-debug folders --- Sprint-3/1-key-errors/0.js | 11 +++++++++-- Sprint-3/1-key-errors/1.js | 14 ++++++++++++-- Sprint-3/1-key-errors/2.js | 18 ++++++++++-------- Sprint-3/2-mandatory-debug/0.js | 10 ++++++++-- Sprint-3/2-mandatory-debug/1.js | 7 ++++++- Sprint-3/2-mandatory-debug/2.js | 16 +++++++++++++--- 6 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..b3ca91136 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,5 +1,5 @@ // Predict and explain first... -// =============> write your prediction here +// It would fail at line 2 with either syntax or reference errors =============> write your prediction here // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring @@ -8,6 +8,13 @@ function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } +console.log(capitalise("beautiful")); -// =============> write your explanation here +// function is assigned 2 arguments/values=============> write your explanation here // =============> write your new code here + +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} +console.log(capitalise("beautiful")); diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..fb61bc780 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,7 +1,7 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// decimalNumber is called twice=============> write your prediction here // Try playing computer with the example to work out what is going on @@ -14,7 +14,17 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// =============> write your explanation here +// decimalNumber has been declared as a function and a variable within function scope=============> write your explanation here +//Removing const decimalNumber still returns Syntax error if still within the function scope so it's not restricted to the function // Finally, correct the code to fix the problem // =============> write your new code here + +function convertToPercentage(decimalNumber) { + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} +const decimalNumber = 0.5; + +console.log(decimalNumber); diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..39f6a6fd8 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,22 @@ - // 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 +// Unidentified function error due to a random number =============> write your prediction of the error here -function square(3) { - return num * num; -} +//function square(num) { +//return square = num * num; +//} -// =============> write the error message here +// Syntax errorError Unexpected number.=============> write the error message here -// =============> explain this error message here +// Means Function identifier should be a name not a number =============> explain this error message here // Finally, correct the code to fix the problem // =============> write your new code here - +function square(num) { + return (square = num * num); +} +console.log(square(3)); diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..ad01aa730 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,6 +1,6 @@ // Predict and explain first... -// =============> write your prediction here +// Code will fail because a , b are not declared values or double function values=============> write your prediction here function multiply(a, b) { console.log(a * b); @@ -9,6 +9,12 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here - +//The 2nd console log returned value value is undefined. I have added a return function to output the multiply value. // Finally, correct the code to fix the problem // =============> write your new code here +function multiply(a, b) { + console.log(a * b); + return a * b; +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..0151c6c78 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,5 +1,6 @@ // Predict and explain first... // =============> write your prediction here +// I think code will run without an error although not entirely sure what the empty return; will return function sum(a, b) { return; @@ -8,6 +9,10 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// =============> write your explanation here +// Maybe that unassigned return; may cause the code not to run fully =============> write your explanation here // Finally, correct the code to fix the problem // =============> write your new code here +function sum(a, b) { + return a + b; +} +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..fc0a28db2 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -2,23 +2,33 @@ // Predict the output of the following code: // =============> Write your prediction here - -const num = 103; +//I think const being declared before function may cause a problem on returning num value (line 10) function getLastDigit() { + const num = 103; 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)}`); // Now run the code and compare the output to your prediction // =============> write the output here +// My prediction was close regarding line 10 as the value of num is not returned. // Explain why the output is the way it is // =============> write your explanation here +// The code has returned 3 as the last digit for all provided numbers because num value is restricted to 103 as value and can't be used outside the function +// Also function getLastDigit() has no parameter set // 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 +// getLastDigit was no working as variable num was taking precedence From 620e7c7c8865423469c7202915e817afb5cc4422 Mon Sep 17 00:00:00 2001 From: Carol Date: Sun, 27 Sep 2026 10:32:02 +0100 Subject: [PATCH 2/4] updated all Sprint-3 files in the key errors, mandatory debug, mandatory implement and mandatory interpret folders --- Sprint-3/1-key-errors/0.js | 2 +- Sprint-3/1-key-errors/1.js | 2 +- Sprint-3/1-key-errors/2.js | 2 +- Sprint-3/2-mandatory-debug/0.js | 2 +- Sprint-3/2-mandatory-debug/1.js | 2 +- Sprint-3/2-mandatory-debug/2.js | 2 +- Sprint-3/3-mandatory-implement/1-bmi.js | 6 +++ Sprint-3/3-mandatory-implement/2-cases.js | 7 ++++ Sprint-3/3-mandatory-implement/3-to-pounds.js | 42 +++++++++++++++++++ Sprint-3/4-mandatory-interpret/time-format.js | 5 +++ 10 files changed, 66 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index b3ca91136..d7ee4664a 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -2,7 +2,7 @@ // It would fail at line 2 with either syntax or reference errors =============> write your prediction here // call the function capitalise with a string input -// interpret the error message and figure out why an error is occurring +// interpret the error message and figure out why an error is occurring. function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index fb61bc780..3a4aa8e05 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -17,7 +17,7 @@ console.log(decimalNumber); // decimalNumber has been declared as a function and a variable within function scope=============> write your explanation here //Removing const decimalNumber still returns Syntax error if still within the function scope so it's not restricted to the function -// Finally, correct the code to fix the problem +// Finally, correct the code to fix the problem. // =============> write your new code here function convertToPercentage(decimalNumber) { diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 39f6a6fd8..fa50872e0 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -10,7 +10,7 @@ // Syntax errorError Unexpected number.=============> write the error message here -// Means Function identifier should be a name not a number =============> explain this error message here +// Means Function identifier should be a name not a number =============> explain this error message here. // Finally, correct the code to fix the problem diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index ad01aa730..30afc1692 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,4 +1,4 @@ -// Predict and explain first... +// Predict and explain first.... // Code will fail because a , b are not declared values or double function values=============> write your prediction here diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 0151c6c78..727f3d0a7 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,4 +1,4 @@ -// Predict and explain first... +// Predict and explain first.... // =============> write your prediction here // I think code will run without an error although not entirely sure what the empty return; will return diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index fc0a28db2..40200ff44 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -12,7 +12,7 @@ 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 +// Now run the code and compare the output to your prediction. // =============> write the output here // My prediction was close regarding line 10 as the value of num is not returned. // Explain why the output is the way it is diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..211fdcd30 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -17,3 +17,9 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height } + +function calculateBMI(weight, height) { + return (weight / height).toFixed(1); +} +console.log(`the bmi of 70 and 2.99 is ${calculateBMI(70, 2.99)}`); +console.log(`the bmi of 90 and 1.96 is ${calculateBMI(90, 1.96)}`); diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..5a2430892 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,10 @@ // 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(text) { + return text.trim().replace(/\s+/g, "_").toUpperCase(); +} + +const result = toUpperSnakeCase("Hello there"); +console.log(result); diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 10754da73..5c76f0024 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,45 @@ // 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 + +/* const penceString = "399p"; + +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"); + +console.log(`£${pounds}.${pence}`);*/ + +// Revised code: +function poundsToPence(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(poundsToPence("499p")); +console.log(poundsToPence("1009p")); +console.log(poundsToPence("2999p")); diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..d82251474 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -22,17 +22,22 @@ 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 because of the 3 arguments // 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 +0; // c) What is the return value of pad when it is called for the first time? // =============> write your answer here +0; // 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 is 1 because the last pad argument is remainingSeconds. So 61 as the given seconds - remaining seconds = 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 +// The answer is 01 because of the final output for formatTimeDisplay(61) is 00:01:01. The assigned value of 1 with the length of 1, the numString = "0" + numString becomes 1 From 3365fc9914c107db17ac19dcc462a930a54de904 Mon Sep 17 00:00:00 2001 From: Carol Date: Wed, 30 Sep 2026 22:19:29 +0100 Subject: [PATCH 3/4] corrected issues raised from run 1 --- Sprint-3/1-key-errors/0.js | 5 ++++- Sprint-3/1-key-errors/1.js | 8 +++++--- Sprint-3/1-key-errors/2.js | 3 +++ Sprint-3/2-mandatory-debug/0.js | 4 +++- Sprint-3/2-mandatory-debug/1.js | 4 +++- Sprint-3/3-mandatory-implement/1-bmi.js | 4 +++- Sprint-3/3-mandatory-implement/2-cases.js | 11 ++++++++--- Sprint-3/3-mandatory-implement/3-to-pounds.js | 10 ++++++---- Sprint-3/4-mandatory-interpret/time-format.js | 2 +- 9 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index d7ee4664a..7d2965c9c 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -10,7 +10,10 @@ function capitalise(str) { } console.log(capitalise("beautiful")); -// function is assigned 2 arguments/values=============> write your explanation here +// write your explanation here: +// Syntax Error: Identifier 'Str' has been already been declared/assigned +// The error means Str had already been identified in the function capitalise(str). Let str is assigning a second value which is causing that error message + // =============> write your new code here function capitalise(str) { diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index 3a4aa8e05..73817f5d3 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,7 +1,8 @@ // Predict and explain first... // Why will an error occur when this program runs? -// decimalNumber is called twice=============> write your prediction here +// write your prediction here +// This is because the variable name for the parameter and the cont is the same // Try playing computer with the example to work out what is going on @@ -14,8 +15,9 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); -// decimalNumber has been declared as a function and a variable within function scope=============> write your explanation here -//Removing const decimalNumber still returns Syntax error if still within the function scope so it's not restricted to the function +//=============> write your explanation here +//The decimalNumber is declared twice as a result, calling convertToPercentage function and passing a value gets assigned to parameter decimalNumber +//So i had to move it outside of the function scope to remove restrictions // Finally, correct the code to fix the problem. // =============> write your new code here diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index fa50872e0..daa01a1e3 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -11,6 +11,9 @@ // Syntax errorError Unexpected number.=============> write the error message here // Means Function identifier should be a name not a number =============> explain this error message here. +// Whats the difference between function identifier and parameter? +// I believe function and identifier and parameter can be used interchangeably. So Parsing number 3 into the parameter would throw an error. +// Changing number 3 to 'num' as a placeholder fixes the error // Finally, correct the code to fix the problem diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 30afc1692..9b2aba501 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -10,7 +10,9 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here //The 2nd console log returned value value is undefined. I have added a return function to output the multiply value. -// Finally, correct the code to fix the problem +//The value returned by the function was undefined because the value hasn't been stored anywhere, and there's no return to return the value to the function call. + +//Finally, correct the code to fix the problem // =============> write your new code here function multiply(a, b) { console.log(a * b); diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 727f3d0a7..a8339e4a6 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -9,7 +9,9 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); -// Maybe that unassigned return; may cause the code not to run fully =============> write your explanation here +// =============> write your explanation here +// The return statement was placed before the expression hence the undefined outcome. The parsed argument is not receiving output. + // Finally, correct the code to fix the problem // =============> write your new code here function sum(a, b) { diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 211fdcd30..497f1d565 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -19,7 +19,9 @@ function calculateBMI(weight, height) { } function calculateBMI(weight, height) { - return (weight / height).toFixed(1); + // return (weight / height).toFixed(1); - 1st attempt + return (weight / (height * height)).toString().slice(0, 4); } + console.log(`the bmi of 70 and 2.99 is ${calculateBMI(70, 2.99)}`); console.log(`the bmi of 90 and 1.96 is ${calculateBMI(90, 1.96)}`); diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5a2430892..480c55dfe 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,10 +14,15 @@ // 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(text) { - return text.trim().replace(/\s+/g, "_").toUpperCase(); + // return text.trim().replace(/\s+/g, "_").toUpperCase(); - first attempt that inserted underscore + return text.toUpperCase().replaceAll(" ", "_"); } -const result = toUpperSnakeCase("Hello there"); -console.log(result); +const text = toUpperSnakeCase("Hello there"); +console.log(text); + +// Trim and regex pattern was the only saving grace I came across to resolve the underscore issue I had spent hours researching. +// I have however now modified and replaced the pattern for easy understanding with AI's help diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 5c76f0024..e270166de 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -25,7 +25,7 @@ const pence = paddedPenceNumberString console.log(`£${pounds}.${pence}`);*/ // Revised code: -function poundsToPence(penceString) { +function toPounds(penceString) { const penceStringWithoutTrailingP = penceString.substring( 0, penceString.length - 1, @@ -43,6 +43,8 @@ function poundsToPence(penceString) { return `£${pounds}.${pence}`; } -console.log(poundsToPence("499p")); -console.log(poundsToPence("1009p")); -console.log(poundsToPence("2999p")); +console.log(toPounds("499p")); +console.log(toPounds("1009p")); +console.log(toPounds("2999p")); + +// updated function name diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index d82251474..30265787e 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -32,7 +32,7 @@ function formatTimeDisplay(seconds) { // c) What is the return value of pad when it is called for the first time? // =============> write your answer here -0; +//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 From ed4e7a2613f6f188f00e30ee2a26ea98e9b643cf Mon Sep 17 00:00:00 2001 From: Carol Date: Sat, 3 Oct 2026 09:25:02 +0100 Subject: [PATCH 4/4] updated files from the last run --- Sprint-3/1-key-errors/2.js | 4 ++-- Sprint-3/3-mandatory-implement/1-bmi.js | 5 +++-- Sprint-3/3-mandatory-implement/2-cases.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index daa01a1e3..0fb0fefa0 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -12,7 +12,7 @@ // Means Function identifier should be a name not a number =============> explain this error message here. // Whats the difference between function identifier and parameter? -// I believe function and identifier and parameter can be used interchangeably. So Parsing number 3 into the parameter would throw an error. +// The parameter of a function must be name not number. So Parsing number 3 into the parameter would throw an error. // Changing number 3 to 'num' as a placeholder fixes the error // Finally, correct the code to fix the problem @@ -20,6 +20,6 @@ // =============> write your new code here function square(num) { - return (square = num * num); + return num * num; } console.log(square(3)); diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 497f1d565..3b60ee513 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -19,8 +19,9 @@ function calculateBMI(weight, height) { } function calculateBMI(weight, height) { - // return (weight / height).toFixed(1); - 1st attempt - return (weight / (height * height)).toString().slice(0, 4); + //return (weight / height).toFixed(1); - 1st attempt + //return (weight / (height * height)).toString().slice(0, 4); - 2nd attempt + return "${(weight / (height * height)).toFixed(1)}"; } console.log(`the bmi of 70 and 2.99 is ${calculateBMI(70, 2.99)}`); diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 480c55dfe..3fe4abe90 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -26,3 +26,4 @@ console.log(text); // Trim and regex pattern was the only saving grace I came across to resolve the underscore issue I had spent hours researching. // I have however now modified and replaced the pattern for easy understanding with AI's help +// CodeYourFuture AI Usage Guide reviewed again