From b285176131960a07deb98aca1e6e12cdafd7b1d8 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Tue, 15 Sep 2026 14:00:06 +0100 Subject: [PATCH 01/13] Create sprint-2 --- Sprint-2/coursework/sprint-2 | 1 + 1 file changed, 1 insertion(+) create mode 100644 Sprint-2/coursework/sprint-2 diff --git a/Sprint-2/coursework/sprint-2 b/Sprint-2/coursework/sprint-2 new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/Sprint-2/coursework/sprint-2 @@ -0,0 +1 @@ + From ef676e6d4c45329025505494584c8d8f501c25b1 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Tue, 15 Sep 2026 14:01:20 +0100 Subject: [PATCH 02/13] Delete Sprint-2/coursework directory --- Sprint-2/coursework/sprint-2 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Sprint-2/coursework/sprint-2 diff --git a/Sprint-2/coursework/sprint-2 b/Sprint-2/coursework/sprint-2 deleted file mode 100644 index 8b1378917..000000000 --- a/Sprint-2/coursework/sprint-2 +++ /dev/null @@ -1 +0,0 @@ - From d0828f2e6e9fd3ed65772e4e2b30a00e96632b00 Mon Sep 17 00:00:00 2001 From: Bartosz Kawiak Date: Thu, 17 Sep 2026 18:06:45 +0100 Subject: [PATCH 03/13] key error 0.js completed --- Sprint-3/1-key-errors/0.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..ac455e67d 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,24 @@ // Predict and explain first... -// =============> write your prediction here +/* =============> I predict that the function would make 1st character uppercase and +then adds the rest of the string using slice. */ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring +//We cannot declare str again because it has already been declared as a parameter of the function. + +/* OLD CODE + function capitalise(str) { let str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } + */ // =============> write your explanation here // =============> write your new code here + +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} From e67a022739d7c7bbe97b695e2e3211a751797ead Mon Sep 17 00:00:00 2001 From: Bartosz Kawiak Date: Fri, 18 Sep 2026 11:29:17 +0100 Subject: [PATCH 04/13] 1-key-errors sprint3 completed --- Sprint-3/1-key-errors/1.js | 13 +++++++++++-- Sprint-3/1-key-errors/2.js | 14 +++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..cb5e75d5a 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,10 +1,11 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// =============> We will get a SyntaxError as decimalNumber has already been declared as a parameter of the function. // Try playing computer with the example to work out what is going on +/* function convertToPercentage(decimalNumber) { const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; @@ -12,9 +13,17 @@ function convertToPercentage(decimalNumber) { return percentage; } -console.log(decimalNumber); +console.log(decimalNumber); */ // =============> write your explanation here +// We don't need to redeclare decimalNumber as it's value comes from function parameter, +// also console.log wont work as decimalNumber is only created inside the function. // 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)); diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..1b52a029c 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -3,18 +3,22 @@ // this function should square any number but instead we're going to get an error -// =============> write your prediction of the error here +// =============> SyntaxError because function parameter must be a name not a number or value. The error occurs because 3 is a number. +/* function square(3) { return num * num; -} +} */ -// =============> write the error message here +// =============> SyntaxError: Unexpected number -// =============> explain this error message here +// =============> This error message is cause by trying to assign a number as a parameter, a parameter needs to be identifier such as num. // Finally, correct the code to fix the problem // =============> write your new code here - +function square(num) { + return num * num; +} +console.log(square(5)) From 989aa0b1e661e09b5951a22414696caa1ffe1fae Mon Sep 17 00:00:00 2001 From: Bartosz Kawiak Date: Fri, 18 Sep 2026 11:53:28 +0100 Subject: [PATCH 05/13] 2-mandatory-debug sprint3 completed --- Sprint-3/2-mandatory-debug/0.js | 14 ++++++++++++-- Sprint-3/2-mandatory-debug/1.js | 11 +++++++++-- Sprint-3/2-mandatory-debug/2.js | 23 ++++++++++++++++++++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..5b64d853b 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,24 @@ // Predict and explain first... -// =============> write your prediction here +// =============> We will log the result in a console but function won't return it as a value. +// console.log only displays the result, it does not return it from the function. +/* 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 +//We need to return a * b so the result can be used where the function is called. + // 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)}`); diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..38b99b4ed 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,20 @@ // Predict and explain first... -// =============> write your prediction here - +// =============> return on its own means that the function ends without returning a value, so the result is undefined. +/* function sum(a, b) { return; a + b; } console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); +*/ // =============> write your explanation here +// return on it's own means that the function wont refer to parameters and will come up as undefined. a+ b is never reached because it comes after return. // 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..90e6423c4 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -1,8 +1,11 @@ // 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; function getLastDigit() { @@ -12,13 +15,31 @@ function getLastDigit() { 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 +/*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 output is this way as there is a num assigned before the function and function don't use the parameter num, +//so the output would only be the return of slice value for const num before the function. + // Finally, correct the code to fix the problem // =============> write your new code here +const num = 103; + +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 +//Function was not working correctly as it was returning num slice for const num that was assigned before the function, function should use parameter num to work correctly. \ No newline at end of file From c0d3b07a141999bd6bb44bd7f2266fd4e5f3302c Mon Sep 17 00:00:00 2001 From: Bartosz Kawiak Date: Fri, 18 Sep 2026 12:02:43 +0100 Subject: [PATCH 06/13] 1-bmi completed --- Sprint-3/3-mandatory-implement/1-bmi.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..e9c9f02b4 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,5 +15,9 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height + let bmiNum = weight / (height * height) + bmiNum=bmiNum.toFixed(1) + return bmiNum } + +console.log(calculateBMI(70,1.73)); From 29c88fd2f6e0485eb40f2d3d98c475057130781f Mon Sep 17 00:00:00 2001 From: Bartosz Kawiak Date: Fri, 18 Sep 2026 12:46:12 +0100 Subject: [PATCH 07/13] 3-mandatory-implement sprint3 completed --- Sprint-3/3-mandatory-implement/2-cases.js | 7 +++ Sprint-3/3-mandatory-implement/3-to-pounds.js | 43 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..5414a655b 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 + +const str= "hello there" + +function strToUpperCase(str) { + return str.toUpperCase().replaceAll(" ","_") +} +console.log(strToUpperCase("lord of the rings")); \ No newline at end of file diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 10754da73..358f827ce 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,46 @@ // 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 + +// In Sprint-1, there is a program written in 3-mandatory-interpret/3-to-pounds.js + +// You will need to take this code and turn it into a reusable block of code. +// 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}`); +*/ + +function toPounds(penceString) { + let noP = penceString.substring(0,penceString.length -1) + let paddedP = noP.padStart(3,"0") + let pounds= paddedP.substring(0, paddedP.length -2) + + let pence= paddedP.substring(paddedP.length -2).padEnd(2,"0") + + return `£${pounds}.${pence}` +} +console.log(toPounds("399p")) +console.log(toPounds("5p")) +console.log(toPounds("52p")) +console.log(toPounds("1244p")) \ No newline at end of file From da1df5fe5dafe7b6c18aaff7a6398a5ea645e682 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Wed, 23 Sep 2026 14:40:27 +0100 Subject: [PATCH 08/13] 4-mandatory-interpret completed --- Sprint-3/4-mandatory-interpret/time-format.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..cc5a52b36 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -15,24 +15,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 +// =============> pad function will be called 3 times because it's been called 3 times in return statement. // 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 +// =============> Starting value is 0 // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here +// =============> returning value of pad when its called for the 2nd time is "00" :numString = "0" + numString: // 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 +// =============> When pad is called for the last time it's value is 1, The last call is pad(remainingSeconds), and remainingSeconds is 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 +// =============> // Return value is "01", num is 1, which becomes "1". Since its length is less than 2, the while loop adds "0" to the beginning, making it "01". From eabe4c7728ab564da039ab8ce4af7179752756a3 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Wed, 23 Sep 2026 16:32:17 +0100 Subject: [PATCH 09/13] sprint3-completed --- Sprint-3/5-stretch-extend/format-time.js | 62 ++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..57d853ff4 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -4,8 +4,13 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = Number(time.slice(3, 5)); if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${(hours - 12).toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")} pm`; + } else if (hours === 12) { + return `${hours}:${minutes.toString().padStart(2, "0")} pm`; + } else if (hours === 0) { + return `12:${minutes.toString().padStart(2, "0")} am`; } return `${time} am`; } @@ -14,12 +19,63 @@ const currentOutput = formatAs12HourClock("08:00"); const targetOutput = "08: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}`, ); + +formatAs12HourClock("19:00"); +let output = formatAs12HourClock("19:00"); +let target = "07:00 pm"; +console.assert( + output === target, + `current output: ${output}, target output: ${target}`, +); +console.log(formatAs12HourClock("19:00")); +// //works +formatAs12HourClock("9:00"); +output = formatAs12HourClock("9:00"); +target = "9:00 am"; +console.assert( + output === target, + `current output: ${output}, target output: ${target}`, +); +console.log(formatAs12HourClock("9:00")); +// //works +formatAs12HourClock("12:00"); +output = formatAs12HourClock("12:00"); +target = "12:00 pm"; +console.assert( + output === target, + `current output: ${output}, target output: ${target}`, +); + +console.log(formatAs12HourClock("12:00")); +//Function needs else if statement to includes code behavior when "12:00" will be the argument value. + +console.log(formatAs12HourClock("9:00")); +// //works +formatAs12HourClock("00:00"); +output = formatAs12HourClock("00:00"); +target = "12:00 am"; +console.assert( + output === target, + `current output: ${output}, target output: ${target}`, +); +console.log(formatAs12HourClock("00:00")); +//Function needs else if statement to includes code behavior when "00:00" will be the argument value. + +formatAs12HourClock("19:37"); +output = formatAs12HourClock("19:37"); +target = "07:37 pm"; +console.assert( + output === target, + `current output: ${output}, target output: ${target}`, +); +console.log(formatAs12HourClock("19:37")); +//For the test to pass I had to create a minutes variable to extract the minutes from the input. When minutes were converted to a number, zero at the start of the string was removed, so padStart(2, "0") was used to add it back. From 3fdce9e7578e2ebfbe6f10da213ef34248641d37 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Sat, 26 Sep 2026 14:25:13 +0100 Subject: [PATCH 10/13] 2-mandatory-debug formatted prettier --- Sprint-3/2-mandatory-debug/0.js | 1 - Sprint-3/2-mandatory-debug/1.js | 4 ++-- Sprint-3/2-mandatory-debug/2.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index 5b64d853b..5e4e34f65 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -10,7 +10,6 @@ function multiply(a, b) { console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); */ - // =============> write your explanation here //We need to return a * b so the result can be used where the function is called. diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 38b99b4ed..6fb07d635 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -14,7 +14,7 @@ console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // Finally, correct the code to fix the problem // =============> write your new code here function sum(a, b) { - return 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 90e6423c4..ab8a87e19 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -42,4 +42,4 @@ 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 -//Function was not working correctly as it was returning num slice for const num that was assigned before the function, function should use parameter num to work correctly. \ No newline at end of file +//Function was not working correctly as it was returning num slice for const num that was assigned before the function, function should use parameter num to work correctly. From fc6e83d15eb2841e9b05a9f5a1376bf454684b89 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Sat, 26 Sep 2026 15:14:34 +0100 Subject: [PATCH 11/13] prettier applied to the files --- Sprint-3/1-key-errors/1.js | 4 ++-- Sprint-3/1-key-errors/2.js | 6 ++---- Sprint-3/3-mandatory-implement/1-bmi.js | 8 +++---- Sprint-3/3-mandatory-implement/2-cases.js | 6 +++--- Sprint-3/3-mandatory-implement/3-to-pounds.js | 21 +++++++++---------- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index cb5e75d5a..18304f478 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -16,8 +16,8 @@ function convertToPercentage(decimalNumber) { console.log(decimalNumber); */ // =============> write your explanation here -// We don't need to redeclare decimalNumber as it's value comes from function parameter, -// also console.log wont work as decimalNumber is only created inside the function. +// We don't need to redeclare decimalNumber as it's value comes from function parameter, +// also console.log wont work as decimalNumber is only created inside the function. // 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 1b52a029c..b5741d024 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,4 +1,3 @@ - // Predict and explain first BEFORE you run any code... // this function should square any number but instead we're going to get an error @@ -18,7 +17,6 @@ function square(3) { // =============> write your new code here function square(num) { - return num * num; + return num * num; } -console.log(square(5)) - +console.log(square(5)); diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index e9c9f02b4..96535a697 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,9 +15,9 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - let bmiNum = weight / (height * height) - bmiNum=bmiNum.toFixed(1) - return bmiNum + let bmiNum = weight / (height * height); + bmiNum = bmiNum.toFixed(1); + return bmiNum; } -console.log(calculateBMI(70,1.73)); +console.log(calculateBMI(70, 1.73)); diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5414a655b..241d00226 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -15,9 +15,9 @@ // 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 -const str= "hello there" +const str = "hello there"; function strToUpperCase(str) { - return str.toUpperCase().replaceAll(" ","_") + return str.toUpperCase().replaceAll(" ", "_"); } -console.log(strToUpperCase("lord of the rings")); \ No newline at end of file +console.log(strToUpperCase("lord of the rings")); diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 358f827ce..0c925cc36 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -12,7 +12,6 @@ // You should call this function a number of times to check it works for different inputs - /* const penceString = "399p"; @@ -35,15 +34,15 @@ console.log(`£${pounds}.${pence}`); */ function toPounds(penceString) { - let noP = penceString.substring(0,penceString.length -1) - let paddedP = noP.padStart(3,"0") - let pounds= paddedP.substring(0, paddedP.length -2) - - let pence= paddedP.substring(paddedP.length -2).padEnd(2,"0") + let noP = penceString.substring(0, penceString.length - 1); + let paddedP = noP.padStart(3, "0"); + let pounds = paddedP.substring(0, paddedP.length - 2); + + let pence = paddedP.substring(paddedP.length - 2).padEnd(2, "0"); - return `£${pounds}.${pence}` + return `£${pounds}.${pence}`; } -console.log(toPounds("399p")) -console.log(toPounds("5p")) -console.log(toPounds("52p")) -console.log(toPounds("1244p")) \ No newline at end of file +console.log(toPounds("399p")); +console.log(toPounds("5p")); +console.log(toPounds("52p")); +console.log(toPounds("1244p")); From 457005f5c354e7cbcf070ea1e14c350c868d8c62 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Sat, 26 Sep 2026 16:02:44 +0100 Subject: [PATCH 12/13] 1-key-errors 0.js another approach added --- Sprint-3/1-key-errors/0.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index ac455e67d..a34d3a0be 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -18,7 +18,17 @@ function capitalise(str) { // =============> write your explanation here // =============> write your new code here +//First version below, another approach displayed as a working code + +// function capitalise(str) { +// str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } + function capitalise(str) { - str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; + const firstLetter = str[0]; + const smallStr = str.slice(1); + const upperLetter1 = firstLetter.toUpperCase(); + let newStr = upperLetter1 + smallStr; + return newStr; } From 84732525eb2a0f32261769e49e6bc61be8a5fe90 Mon Sep 17 00:00:00 2001 From: bartoszkawiak Date: Sat, 26 Sep 2026 19:29:47 +0100 Subject: [PATCH 13/13] 3-mandatory-implement questions answered --- Sprint-3/3-mandatory-implement/1-bmi.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 96535a697..3ed68ec7b 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -17,7 +17,22 @@ function calculateBMI(weight, height) { let bmiNum = weight / (height * height); bmiNum = bmiNum.toFixed(1); - return bmiNum; + return typeof bmiNum; } console.log(calculateBMI(70, 1.73)); + +// What type of value do you expect your function to return? A number or a string? +//I expect function to return string as required, toFixed() change the type of number to a string. + +// Does your function return the type of value you expect? +//Yes I did expect a string returned. + +// Different types of values may appear identical in the console output, but they are represented and treated differently in the program. For example, + +// console.log(123); // Output 123(number) +// console.log("123"); // Output 123(string) + +// // Treated differently in the program +// let sum1 = 123 + 100; // Evaluate to 223 -- a number +// let sum 2 = "123" + 100; // Evaluate to "123100" -- a string.