From 418195fa6a5cf67865d3df4e215738d66ff79d76 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Mon, 29 Jun 2026 18:54:27 +0100
Subject: [PATCH 01/12] answered all questions in 0.js
---
Sprint-2/1-key-errors/0.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js
index 653d6f5a07..3cd6a33f5f 100644
--- a/Sprint-2/1-key-errors/0.js
+++ b/Sprint-2/1-key-errors/0.js
@@ -1,13 +1,19 @@
// Predict and explain first...
// =============> write your prediction here
+// the function will throw a syntax error because we are redeclaring 'str'. we can reassign - without using the let keyword.
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
-function capitalise(str) {
- let str = `${str[0].toUpperCase()}${str.slice(1)}`;
- return str;
-}
+// function capitalise(str) {
+// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
+// return str;
+// }
// =============> write your explanation here
+// i will remove the let keyword, which is only used for declaration and assignment, when redeclaring we do not use the let keyword
// =============> write your new code here
+function capitalise(str){
+ str = `${str[0].toUpperCase()}${str.slice(1)}`;
+ return str
+}
\ No newline at end of file
From 8c775761e002f2a966b8eb3aa995e747c8516883 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Mon, 29 Jun 2026 19:26:19 +0100
Subject: [PATCH 02/12] answered all questions in 1.js
---
Sprint-2/1-key-errors/1.js | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js
index f2d56151f4..6ed4a59e99 100644
--- a/Sprint-2/1-key-errors/1.js
+++ b/Sprint-2/1-key-errors/1.js
@@ -2,19 +2,29 @@
// Why will an error occur when this program runs?
// =============> write your prediction here
+/* - The function will throw a syntax error because we have redeclared the parameter variable "decimalNumber", and we have
+ also used const for declaring percentage, percentage will change when we call the function with different arguments so it should
+ be declared using let.
+ - we are console logging the variable decimalNumber outside the function - the variable lives only inside 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}%`;
-
- return percentage;
-}
-
-console.log(decimalNumber);
+// function convertToPercentage(decimalNumber) {
+// const decimalNumber = 0.5;
+// const percentage = `${decimalNumber * 100}%`;
+//
+// return percentage;
+// }
+//
+// console.log(decimalNumber);
// =============> write your explanation here
-
+/*I will remove line 14 - a redeclaration of the parameter variable, we will not reassign it, we will get the decimal
+ number by calling the function with an argument and we will console.log the function call*/
// Finally, correct the code to fix the problem
// =============> write your new code here
+function convertToPercentage(decimalNumber){
+ return `${decimalNumber * 100}%`;
+}
+console.log(convertToPercentage(0.5))
\ No newline at end of file
From 852019fc37fa0fc0b8ba4ed4ac4d33f9008ca151 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Mon, 29 Jun 2026 19:51:11 +0100
Subject: [PATCH 03/12] answered all questions in 2.js
---
Sprint-2/1-key-errors/2.js | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js
index aad57f7cfe..73fa729f49 100644
--- a/Sprint-2/1-key-errors/2.js
+++ b/Sprint-2/1-key-errors/2.js
@@ -1,20 +1,36 @@
// Predict and explain first BEFORE you run any code...
-// this function should square any number but instead we're going to get an error
+// this function should square any number, but instead we're going to get an error
// =============> write your prediction of the error here
+/*The parameter shouldn't be a number, a parameter is a variable and should be able to hold a value for example num
+can hold the variable 3.
+we are also returning num * num but didn't declare num anywhere in our script.
+this function will throw a syntax error
+*/
-function square(3) {
- return num * num;
-}
+// function square(3) {
+// return num * num;
+// }
// =============> write the error message here
+/*
+function square(3) {
+ ^
-// =============> explain this error message here
+SyntaxError: Unexpected number
+*/
+// =============> explain this error message here
+/* The error message is telling us that the number 3 used has the parameter is not syntactically correct, JavaScript
+does not allow a literal number used 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(3))
\ No newline at end of file
From 3a31cc770b666a0a7d5f0deacb2198a57087fd17 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Mon, 29 Jun 2026 19:51:55 +0100
Subject: [PATCH 04/12] added a console.log calling the function in 0.js
---
Sprint-2/1-key-errors/0.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js
index 3cd6a33f5f..28198c11f8 100644
--- a/Sprint-2/1-key-errors/0.js
+++ b/Sprint-2/1-key-errors/0.js
@@ -14,6 +14,7 @@
// i will remove the let keyword, which is only used for declaration and assignment, when redeclaring we do not use the let keyword
// =============> write your new code here
function capitalise(str){
- str = `${str[0].toUpperCase()}${str.slice(1)}`;
+ str = `${str[0].toUpperCase()}${str.slice(0)}`;
return str
-}
\ No newline at end of file
+}
+console.log(capitalise("butter"))
\ No newline at end of file
From 4f02ec17809b068318c98d1bca7196df24f74230 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Mon, 29 Jun 2026 21:11:50 +0100
Subject: [PATCH 05/12] completed 2-mandatory-debug/0.js
---
Sprint-2/2-mandatory-debug/0.js | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js
index b27511b417..e8bceb9f84 100644
--- a/Sprint-2/2-mandatory-debug/0.js
+++ b/Sprint-2/2-mandatory-debug/0.js
@@ -1,14 +1,29 @@
// Predict and explain first...
// =============> write your prediction here
+/* we haven't called the function, when we run the code it will show undefined in the console
+*/
-function multiply(a, b) {
- console.log(a * b);
-}
-console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
+// function multiply(a, b) {
+// console.log(a * b);
+// }
+//
+// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
// =============> write your explanation here
-
+// After running the code it prints:
+// 1. 320
+// 2. The result of multiplying 10 and 32 is undefined
+// I understand that the template string evaluates its content first before printing it, so the function call in the template
+// calls the function and passes the numbers 10 and 32, the functions runs and prints 320 to the console, the template string
+// then print "The result of multiplying 10 and 32 is undefined" - it prints undefined because we do not have a return statement,
+// and when we don't have a return JavaScript returns undefined automatically
// 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)}`);
\ No newline at end of file
From 11253932d6cc03e3e2ed9a870999bacd1aea3269 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Mon, 29 Jun 2026 21:18:05 +0100
Subject: [PATCH 06/12] completed 2-mandatory-debug/1.js
---
Sprint-2/2-mandatory-debug/1.js | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js
index 37cedfbcfd..a02cc80c49 100644
--- a/Sprint-2/2-mandatory-debug/1.js
+++ b/Sprint-2/2-mandatory-debug/1.js
@@ -1,13 +1,20 @@
// Predict and explain first...
// =============> write your prediction here
-
-function sum(a, b) {
- return;
- a + b;
-}
-
-console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
+// we have added a semicolon between the return statement and what we want to return, the semicolon signifies the end
+// of a statement, so a + b will not be returned
+// function sum(a, b) {
+// return;
+// a + b;
+// }
+//
+// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
// =============> write your explanation here
+// I have removed the semicolon right after the return statement
// 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)}`);
\ No newline at end of file
From 0a40c266a7ffdf8c012c10663062d3a1e439d554 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Tue, 30 Jun 2026 19:53:15 +0100
Subject: [PATCH 07/12] completed 2-mandatory-debug/2.js
---
Sprint-2/2-mandatory-debug/2.js | 38 ++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js
index 57d3f5dc35..08dc67a6cb 100644
--- a/Sprint-2/2-mandatory-debug/2.js
+++ b/Sprint-2/2-mandatory-debug/2.js
@@ -2,23 +2,41 @@
// Predict the output of the following code:
// =============> Write your prediction here
-
-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)}`);
+/* we have a variable that is declared in the global scope, and in the function we are returning the variable -num, we also
+ do not have a parameter for the function, but we call the function passing it an argument. we might get an argument error
+*
+*
+* */
+// 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)}`);
// 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 function does not have a parameter, so the arguments are ignored and the function instead uses the global variable
+* */
// 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 21e0b3a08327f6481ab5bba032ca6dc50ec158bc Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Tue, 30 Jun 2026 20:17:51 +0100
Subject: [PATCH 08/12] completed 3-mandatory-implement/1-bmi.js
---
Sprint-2/3-mandatory-implement/1-bmi.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js
index 17b1cbde1b..aba404b022 100644
--- a/Sprint-2/3-mandatory-implement/1-bmi.js
+++ b/Sprint-2/3-mandatory-implement/1-bmi.js
@@ -16,4 +16,7 @@
function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
-}
\ No newline at end of file
+ let bmi = weight / (height * height);
+ return bmi.toFixed(1)
+}
+console.log(calculateBMI(95, 1.78))
\ No newline at end of file
From 998751850be85772401ccfd1cdcfbe1d8975da22 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Tue, 30 Jun 2026 20:35:38 +0100
Subject: [PATCH 09/12] completed 3-mandatory-implement/2-cases.js
---
Sprint-2/3-mandatory-implement/2-cases.js | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js
index 5b0ef77ad9..ea18f8ad91 100644
--- a/Sprint-2/3-mandatory-implement/2-cases.js
+++ b/Sprint-2/3-mandatory-implement/2-cases.js
@@ -14,3 +14,8 @@
// 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 replaceEmptyStrings(str){
+ return str.replaceAll(" ", "_").toUpperCase();
+}
+console.log(replaceEmptyStrings("what is your name"))
\ No newline at end of file
From b4a463645538036d5e964fbcf1003bddaf37a524 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Tue, 30 Jun 2026 21:25:48 +0100
Subject: [PATCH 10/12] completed 3-mandatory-implement/3-to-pounds.js
---
Sprint-2/3-mandatory-implement/3-to-pounds.js | 7 +++++++
1 file changed, 7 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..3070dac649 100644
--- a/Sprint-2/3-mandatory-implement/3-to-pounds.js
+++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js
@@ -4,3 +4,10 @@
// 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(numInPence){
+ let num = Number(numInPence.slice(0, -1))
+ let numberInPounds = num / 100;
+ return `£${numberInPounds.toFixed(2)}`
+}
+console.log(toPounds("21p"))
\ No newline at end of file
From 8b22dfba1c810a818fb7097a634ace3474685b63 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Sat, 4 Jul 2026 20:04:15 +0100
Subject: [PATCH 11/12] completed all questions in const remainingSeconds =
seconds % 60
---
Sprint-2/4-mandatory-interpret/time-format.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js
index 17127bc01e..6da2dbfb65 100644
--- a/Sprint-2/4-mandatory-interpret/time-format.js
+++ b/Sprint-2/4-mandatory-interpret/time-format.js
@@ -22,17 +22,26 @@ 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 1. pad(totalHours) 2.pad(remainingMinutes) 3. pad(remainingSeconds)}
// 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
+// num is 0
// c) What is the return value of pad is called for the first time?
// =============> write your answer here
+// "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
+// num is 1, we are calling the pad with the argument remainingSeconds, when the formatTimeDisplay function was called
+// with the argument 61, the next line of code is a variable declaration and an expression, the resulting value from this
+// expression is passed into pad as an argument.
// 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
+// num is 1 when passed as an argument into pad, the job of the function pad is to pad a zero before a number when said number is
+// less than 2 in length - so the return value will be "01"
+
From e353f01ae2414c10f8f09b66cf7ce62d692a486d Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Sun, 5 Jul 2026 15:06:00 +0100
Subject: [PATCH 12/12] completed 5-stretch-extend/format-time.js
---
Sprint-2/5-stretch-extend/format-time.js | 63 +++++++++++++++++++-----
1 file changed, 52 insertions(+), 11 deletions(-)
diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js
index 32a32e66b8..0fc595fd06 100644
--- a/Sprint-2/5-stretch-extend/format-time.js
+++ b/Sprint-2/5-stretch-extend/format-time.js
@@ -3,23 +3,64 @@
// Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find.
function formatAs12HourClock(time) {
- const hours = Number(time.slice(0, 2));
- if (hours > 12) {
- return `${hours - 12}:00 pm`;
- }
- return `${time} am`;
+ const hours = time.slice(0, 2);
+ const mins = time.slice(3);
+ if (hours > 12) {
+ const hoursIsPastMidday = hours - 12;
+ return `${hoursIsPastMidday}:${mins}pm`
+ } else if (hours === "12") {
+ return `${hours}:${mins}pm`
+ }else if (hours === "00"){
+ return `12:${mins}am`
+ }
+ return `${time}am`
}
const currentOutput = formatAs12HourClock("08:00");
-const targetOutput = "08:00 am";
+const targetOutput = "08:00am";
console.assert(
- currentOutput === targetOutput,
- `current output: ${currentOutput}, target output: ${targetOutput}`
+ currentOutput === targetOutput,
+ `current output: ${currentOutput}, target output: ${targetOutput}`
);
const currentOutput2 = formatAs12HourClock("23:00");
-const targetOutput2 = "11:00 pm";
+const targetOutput2 = "11:00pm";
console.assert(
- currentOutput2 === targetOutput2,
- `current output: ${currentOutput2}, target output: ${targetOutput2}`
+ currentOutput2 === targetOutput2,
+ `current output: ${currentOutput2}, target output: ${targetOutput2}`
);
+
+const currentOutput3 = formatAs12HourClock("00:00");
+const targetOutput3 = "12:00am";
+console.assert(
+ currentOutput3 === targetOutput3,
+ `current output: ${currentOutput3}, target output: ${targetOutput3}`
+);
+
+const currentOutput4 = formatAs12HourClock("17:45");
+const targetOutPut4 = "5:45pm";
+console.assert(
+ currentOutput4 === targetOutPut4,
+ `current output: ${currentOutput4}, target output: ${targetOutPut4}`
+);
+
+const currentOutput5 = formatAs12HourClock("00:01");
+const targetOutPut5= "12:01am";
+console.assert(
+ currentOutput5 === targetOutPut5,
+ `current output: ${currentOutput5}, target output: ${targetOutPut5}`
+);
+
+const currentOutput6 = formatAs12HourClock("00:59");
+const targetOutPut6= "12:59am";
+console.assert(
+ currentOutput6 === targetOutPut6,
+ `current output: ${currentOutput6}, target output: ${targetOutPut6}`
+)
+
+const currentOutput7 = formatAs12HourClock("12:00");
+const targetOutPut7= "12:00pm";
+console.assert(
+ currentOutput7 === targetOutPut7,
+ `current output: ${currentOutput7}, target output: ${targetOutPut7}`
+)