From aeba164e54d5106777119696e9d1cf6b2b3987f7 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Wed, 17 Jun 2026 12:11:27 +0100 Subject: [PATCH 01/13] Explained what line 3 is doing --- Sprint-1/1-key-exercises/1-count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..484eb730c5 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,5 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing + +// Line 3 increases the number by one and reassigns new value to count, which stored 0./// From bf0aa4984f4f6bfe6008d3c66d092e4db7164f3d Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 11:04:25 +0100 Subject: [PATCH 02/13] Fix syntax error --- Sprint-2/1-key-errors/0.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..287e3f3e9b 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -4,10 +4,21 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring +//////// error code ///// + +// function capitalise(str) { +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; +// return str; +// } + +// fix code // function capitalise(str) { - let str = `${str[0].toUpperCase()}${str.slice(1)}`; - return str; + let string = `${str[0].toUpperCase()}${str.slice(1)}`; + return string; } +console.log(capitalise("hello js error")); // =============> write your explanation here // =============> write your new code here + +// The Error was syntax error as "str" has already been declared and we can't declare it again as variable name. Now I declare a new variable name and assign value. From f09ff4b659ea9adb07fd96bb391f4bed567537f2 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 18:33:50 +0100 Subject: [PATCH 03/13] fix syntax error and define erro --- Sprint-2/1-key-errors/1.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f4..d5afc4cd60 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -3,16 +3,18 @@ // Why will an error occur when this program runs? // =============> write your prediction here +// There will be two errors, First syntax errors as decimalNumber has already been declared and tried to redeclare it again inside function. +// second without defining decimalNumber try to use decimalNumber in log. + // Try playing computer with the example to work out what is going on function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(decimalNumber); +console.log(convertToPercentage(0.9)); // =============> write your explanation here From 28dec16aa24746852aa580f539fe4d5168979add Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 19:03:09 +0100 Subject: [PATCH 04/13] fix syntax error and used valid parameter name --- Sprint-2/1-key-errors/2.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..b79fb9bae2 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/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 @@ -6,15 +5,20 @@ // =============> write your prediction of the error here function square(3) { - return num * num; + return num * num; } // =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here +// syntax error as function does not allow actual value as a parameter // Finally, correct the code to fix the problem // =============> write your new code here - +function square(num) { + return num * num; +} +console.log(square(2)); From fbc18f9ffde342f622dc3c76f6658222e7818d18 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 19:54:32 +0100 Subject: [PATCH 05/13] fixed multiply function to return result --- Sprint-2/2-mandatory-debug/0.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b417..af864ffb04 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -10,5 +10,12 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // =============> write your explanation here +// first log will show result by multiplying but second log will not show any result instead will show undefined because we did not say the code +// what to do and what should return. + // Finally, correct the code to fix the problem // =============> write your new code here + +function multiply(a, b) { + return a * b; +} From 82ad98f8e21b39e973d7189fea776ef0a21304b8 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 20:06:44 +0100 Subject: [PATCH 06/13] fixed sum function to return correct value --- Sprint-2/2-mandatory-debug/1.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..358cbedd95 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,6 +1,8 @@ // Predict and explain first... // =============> write your prediction here +// It will show undefined + function sum(a, b) { return; a + b; @@ -9,5 +11,11 @@ function sum(a, b) { console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +// the reason is that I did not write anything inside return that's why return can't find anything to return + // Finally, correct the code to fix the problem // =============> write your new code here + +function sum(a, b) { + return a + b; +} From 9e3b8c1479351e1c930ffb3d2ffa2f91d4b5915e Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 20:40:28 +0100 Subject: [PATCH 07/13] fix getLastDigit to return last digit of any input number --- Sprint-2/2-mandatory-debug/2.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc35..88602f1379 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -2,6 +2,7 @@ // Predict the output of the following code: // =============> Write your prediction here +// I predicted that it will show undefined or fixed number like 3 const num = 103; @@ -15,10 +16,24 @@ 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 +// num has fix number which is 3 and i return this fix number // =============> write your explanation here +// user want last digit whatever number they put but i set up a fix number which will return that one that's why now i removed fixed number and wrote a parameter in function +// which will contain user number whatever number they put and get the last digit. // 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 From df45294aa81ca13f66acdb738d02e87b40f06e67 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 21:08:41 +0100 Subject: [PATCH 08/13] made a bmi calcultor function --- Sprint-2/3-mandatory-implement/1-bmi.js | 10 ++++++++-- 1 file changed, 8 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..2075b159ea 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -15,5 +15,11 @@ // 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 + let allHeight = Number(height * height); + let heightWeight = Number(weight / allHeight); + let oneDecimal = heightWeight.toFixed(1); + return oneDecimal; + + // return the BMI of someone based off their weight and height +} +console.log(calculateBMI(78, 1.77)); From 9513e24556e91cf9271ba5a17ad390bc7e9560e6 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 21:38:15 +0100 Subject: [PATCH 09/13] wrote a function for upper snakecase --- 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..2f665fe52e 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 UpperSnake(string) { + let upper = string.toUpperCase().split(" ").join("_"); + return upper; +} +console.log(UpperSnake("hello py")); From 09bd32f1e7683b03b9e39c8d548f50bf0fa6c0c5 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 26 Jun 2026 22:19:38 +0100 Subject: [PATCH 10/13] added function --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 35 +++++++++++-------- Sprint-2/3-mandatory-implement/3-to-pounds.js | 24 +++++++++++++ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69a..6c83b09fc2 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,21 +1,28 @@ -const penceString = "399p"; +// const penceString = "399p"; -const penceStringWithoutTrailingP = penceString.substring( - 0, - penceString.length - 1 -); +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 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"); -console.log(`£${pounds}.${pence}`); + let poundPence = `£${pounds}.${pence}`; + + return poundPence; +} +console.log(toPounds("223p")); + +// console.log(`£${pounds}.${pence}`); // This program takes a string representing a price in pence // The program then builds up a string representing the price in pounds diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a703..1d1527cda0 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,27 @@ // 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"); + + let poundPence = `£${pounds}.${pence}`; + + return poundPence; +} +console.log(toPounds("223p")); +console.log(toPounds("43p")); +console.log(toPounds("129p")); From 64a649faf97a76edbb6c12eb540e6e9a50e693c1 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 10 Jul 2026 12:56:26 +0100 Subject: [PATCH 11/13] Answered following question in time format --- Sprint-2/4-mandatory-interpret/time-format.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 17127bc01e..2d6a98d9a8 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -15,6 +15,8 @@ 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 @@ -22,17 +24,22 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// Answer : three 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 +// answer : 0 // c) What is the return value of pad is called for the first time? // =============> write your answer here +// Answer : 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 - +// answer : 1 and when pad is called, it is called remainingSecond as argument. when formatDisplay runs(61) then 61 divided by 60 and remaining number is 1,which passed to num, so the value of num 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 +// answer: 01. return value is zero one because first received it one then pad formatted this number with two length. From 19b45045fe5145e53857e288f0636073f2cdb3dc Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Fri, 10 Jul 2026 21:17:12 +0100 Subject: [PATCH 12/13] converted 24 clock to 12 and test group of input and adge cases --- Sprint-2/5-stretch-extend/format-time.js | 35 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b8..2bbdbf1384 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -4,10 +4,16 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const mint = time.slice(-2); if (hours > 12) { return `${hours - 12}:00 pm`; + } else if (hours === 0) { + return `12:${mint} am`; + } else if (hours === 12) { + return `12:${mint} pm`; + } else { + return `${time} am`; } - return `${time} am`; } const currentOutput = formatAs12HourClock("08:00"); @@ -16,10 +22,35 @@ console.assert( currentOutput === 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}` ); + +const currentOutput3 = formatAs12HourClock("00:00"); +const targetOutput3 = "12:00 am"; +console.assert( + currentOutput3 === targetOutput3, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); + +const currentOutput4 = formatAs12HourClock("16:00"); +const targetOutput4 = "04:00 pm"; +console.assert( + currentOutput4 === targetOutput4, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); + +const currentOutput5 = formatAs12HourClock("20:00"); +const targetOutput5 = "08:00 pm"; +console.assert( + currentOutput5 === targetOutput5, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); + +console.log(formatAs12HourClock("08:00")); +console.log(formatAs12HourClock("23:00")); +console.log(formatAs12HourClock("00:00")); +console.log(formatAs12HourClock("16:00")); From 1f547457af4e63f2e9dd54144ece3e38c6f2e348 Mon Sep 17 00:00:00 2001 From: Sayeed Hussain Date: Sat, 11 Jul 2026 13:31:53 +0100 Subject: [PATCH 13/13] fix original files --- Sprint-1/1-key-exercises/1-count.js | 2 -- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 35 ++++++++----------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 484eb730c5..117bcb2b6e 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,5 +4,3 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing - -// Line 3 increases the number by one and reassigns new value to count, which stored 0./// diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 6c83b09fc2..60c9ace69a 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,28 +1,21 @@ -// const penceString = "399p"; +const penceString = "399p"; -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"); - let poundPence = `£${pounds}.${pence}`; - - return poundPence; -} -console.log(toPounds("223p")); - -// console.log(`£${pounds}.${pence}`); +console.log(`£${pounds}.${pence}`); // This program takes a string representing a price in pence // The program then builds up a string representing the price in pounds