From 1f8897790b8437d0b5a608eeabf061852a224b95 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 19:49:52 +0100
Subject: [PATCH 01/12] answered question in 1-count.js
---
Sprint-1/1-key-exercises/1-count.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js
index 117bcb2b6e..a581d152b7 100644
--- a/Sprint-1/1-key-exercises/1-count.js
+++ b/Sprint-1/1-key-exercises/1-count.js
@@ -4,3 +4,6 @@ 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: we are re-assigning count using the assignment operator (=). The " = " is used in JavaScript to assing a value
+// to a variable and in this case we are re-assinging count to equal count + 1.
\ No newline at end of file
From f2ed2f56945a2e81376056c693873d748f71a704 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 20:04:39 +0100
Subject: [PATCH 02/12] completed 2-initials.js and tested it with logging to
the console
---
Sprint-1/1-key-exercises/2-initials.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js
index 47561f6175..4ff9344e2e 100644
--- a/Sprint-1/1-key-exercises/2-initials.js
+++ b/Sprint-1/1-key-exercises/2-initials.js
@@ -5,7 +5,7 @@ let lastName = "Johnson";
// Declare a variable called initials that stores the first character of each string.
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
-let initials = ``;
-
+let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`;
+console.log(initials)
// https://www.google.com/search?q=get+first+character+of+string+mdn
From 302efeee13c9ad3a90b0af7384934db4b4df0e0a Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 20:26:01 +0100
Subject: [PATCH 03/12] completed 3-paths.js and tested it with logging to the
console
---
Sprint-1/1-key-exercises/3-paths.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js
index ab90ebb28e..813a9ad892 100644
--- a/Sprint-1/1-key-exercises/3-paths.js
+++ b/Sprint-1/1-key-exercises/3-paths.js
@@ -12,12 +12,15 @@
const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt";
const lastSlashIndex = filePath.lastIndexOf("/");
const base = filePath.slice(lastSlashIndex + 1);
+
console.log(`The base part of ${filePath} is ${base}`);
// Create a variable to store the dir part of the filePath variable
// Create a variable to store the ext part of the variable
-const dir = ;
-const ext = ;
+const dir = filePath.slice(1 , 44);
+console.log(dir)
+ const ext = filePath.slice(lastSlashIndex + 5 );
+console.log(ext)
// https://www.google.com/search?q=slice+mdn
\ No newline at end of file
From 63ea100f32995164a7ca035bdc52f4f05e101795 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 22:13:53 +0100
Subject: [PATCH 04/12] completed 4-random.js and tested it with logging to the
console
---
Sprint-1/1-key-exercises/4-random.js | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js
index 292f83aabb..902ff68b11 100644
--- a/Sprint-1/1-key-exercises/4-random.js
+++ b/Sprint-1/1-key-exercises/4-random.js
@@ -2,8 +2,26 @@ const minimum = 1;
const maximum = 100;
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
+console.log(num)
+
+
+ //In this exercise, you will need to work out what num represents?
+ //Try breaking down the expression and using documentation to explain what it means
+ //It will help to think about the order in which expressions are evaluated
+ //Try logging the value of num and running the program several times to build an idea of what the program is doing
+
+/*
+Answer
+
+num is a variable that'll hold the output of the expression in line 4, I have run the code several times and I get a
+different number each run.
+Math.random returns a random decimal number between 0 (inclusive) and 1 (exclusive).
+Math.floor rounds the number to the nearest integer.
+This expression is evaluated according to parenthesis and operator precedence, so for this expression it will be as follows:
+1. (maximum - minimum + 1)
+2. Math.random() is called
+3. result from Math.random * result from > maximum - minimum + 1
+4. Math.floor is then called with (Math.random * result from > maximum - minimum + 1)
+5. result from Math.floor + minimum
+*/
-// In this exercise, you will need to work out what num represents?
-// Try breaking down the expression and using documentation to explain what it means
-// It will help to think about the order in which expressions are evaluated
-// Try logging the value of num and running the program several times to build an idea of what the program is doing
From 7f35b334ed31b2b19a147b522f699c6eff70fff6 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 22:19:31 +0100
Subject: [PATCH 05/12] Answered question in 0.js
---
Sprint-1/2-mandatory-errors/0.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js
index cf6c5039f7..906fd0c02f 100644
--- a/Sprint-1/2-mandatory-errors/0.js
+++ b/Sprint-1/2-mandatory-errors/0.js
@@ -1,2 +1,5 @@
-This is just an instruction for the first activity - but it is just for human consumption
-We don't want the computer to run these 2 lines - how can we solve this problem?
\ No newline at end of file
+/*This is just an instruction for the first activity - but it is just for human consumption
+We don't want the computer to run these 2 lines - how can we solve this problem?*/
+
+//Answer
+//We will comment it out.
\ No newline at end of file
From e6d78a0cc4595c2aa18de9b5e37b3298ea95a327 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 22:23:44 +0100
Subject: [PATCH 06/12] completed task in 1.js
---
Sprint-1/2-mandatory-errors/1.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js
index 7a43cbea76..712f9bd92a 100644
--- a/Sprint-1/2-mandatory-errors/1.js
+++ b/Sprint-1/2-mandatory-errors/1.js
@@ -1,4 +1,8 @@
// trying to create an age variable and then reassign the value by 1
-const age = 33;
+/* we cannot reassign a variable that was declared using the const keyword so we will change it to the let keyword
+ which allows us to reassign variables*/
+
+let age = 33;
age = age + 1;
+console.log(age)
From 4ffd3030d28015528eb04b223e5f7b4deb1d6e1e Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 22:27:52 +0100
Subject: [PATCH 07/12] fixed the error in 2.js
---
Sprint-1/2-mandatory-errors/2.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js
index e09b89831d..47f6fd669f 100644
--- a/Sprint-1/2-mandatory-errors/2.js
+++ b/Sprint-1/2-mandatory-errors/2.js
@@ -1,5 +1,9 @@
// Currently trying to print the string "I was born in Bolton" but it isn't working...
// what's the error ?
-console.log(`I was born in ${cityOfBirth}`);
const cityOfBirth = "Bolton";
+console.log(`I was born in ${cityOfBirth}`);
+
+
+/* The variable is declared after it's been used and when we run the code we get this > ReferenceError: Cannot access
+ 'cityOfBirth' before initialization */
\ No newline at end of file
From 78253f11328fe07b0b946d7cdf86099973ed5bec Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 23:29:53 +0100
Subject: [PATCH 08/12] fixed the error in 3.js and the code now runs
---
Sprint-1/2-mandatory-errors/3.js | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js
index ec101884db..a35409662a 100644
--- a/Sprint-1/2-mandatory-errors/3.js
+++ b/Sprint-1/2-mandatory-errors/3.js
@@ -1,5 +1,11 @@
-const cardNumber = 4533787178994213;
-const last4Digits = cardNumber.slice(-4);
+//const cardNumber = 4533787178994213;
+//const last4Digits = cardNumber.slice(-4);
+
+
+// to fix the code, we'll convert the number to a string because .slice does not work on number data type
+let cardNumber = 4533787178994213;
+cardNumber = cardNumber.toString()
+let last4Digits = cardNumber.slice(-4);
// The last4Digits variable should store the last 4 digits of cardNumber
// However, the code isn't working
@@ -7,3 +13,10 @@ const last4Digits = cardNumber.slice(-4);
// Then run the code and see what error it gives.
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
+
+//Answer
+// We are not logging to the console
+// The slice method should be a positive number to represent the index position.
+
+console.log(last4Digits)
+//TypeError: cardNumber.slice is not a function
\ No newline at end of file
From df2d21411e027607b281d29ccd7ce46becf4bdd4 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Wed, 17 Jun 2026 23:33:50 +0100
Subject: [PATCH 09/12] fixed the variable naming in 4.js
---
Sprint-1/2-mandatory-errors/4.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js
index 5f86c730bc..427d683da5 100644
--- a/Sprint-1/2-mandatory-errors/4.js
+++ b/Sprint-1/2-mandatory-errors/4.js
@@ -1,2 +1,4 @@
-const 12HourClockTime = "8:53pm";
-const 24hourClockTime = "20:53";
+const _12HourClockTime = "8:53pm";
+const $24hourClockTime = "20:53";
+
+//when starting a variable name with a number we have to precede with either of _ or $
\ No newline at end of file
From d8e5852c333acd3e015dadecc69ae9f13381e275 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Thu, 18 Jun 2026 18:28:37 +0100
Subject: [PATCH 10/12] answered all questions in 1-percentage-change.js
---
Sprint-1/3-mandatory-interpret/1-percentage-change.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js
index e24ecb8e18..30ec3e8f69 100644
--- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js
+++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js
@@ -2,7 +2,7 @@ let carPrice = "10,000";
let priceAfterOneYear = "8,543";
carPrice = Number(carPrice.replaceAll(",", ""));
-priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
+priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
const priceDifference = carPrice - priceAfterOneYear;
const percentageChange = (priceDifference / carPrice) * 100;
@@ -12,11 +12,18 @@ console.log(`The percentage change is ${percentageChange}`);
// Read the code and then answer the questions below
// a) How many function calls are there in this file? Write down all the lines where a function call is made
+// There are 3 function calls. line 4 Number() and .replaceAll()
+// line 12 console,log()
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
+//A syntaxError is occurring on line 5, we are missing a "," and a closing ")"
// c) Identify all the lines that are variable reassignment statements
+// line 4 and 5
// d) Identify all the lines that are variable declarations
-
+// line 1, 2, 7, 8
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
+/* We are removing the comma, the replaceAll method takes in two arguements, 1 for what to replace and 2 for what to
+replace by, and in this case we are replaceing the comma with an empty string. we wrap the carPrice variable which is a string
+with the Number() function to convert it into a number*/
\ No newline at end of file
From bae8454e3a2b019bd33c46e402a644fc44d68bb8 Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Thu, 18 Jun 2026 18:59:36 +0100
Subject: [PATCH 11/12] answered all questions in 2-time-format.js
---
Sprint-1/3-mandatory-interpret/2-time-format.js | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js
index 47d2395587..51f9a04d74 100644
--- a/Sprint-1/3-mandatory-interpret/2-time-format.js
+++ b/Sprint-1/3-mandatory-interpret/2-time-format.js
@@ -1,4 +1,5 @@
-const movieLength = 8784; // length of movie in seconds
+// const movieLength = 8784; // length of movie in seconds
+const movieLength = 879094; // length of movie in seconds
const remainingSeconds = movieLength % 60;
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +13,24 @@ console.log(result);
// For the piece of code above, read the code and then answer the following questions
// a) How many variable declarations are there in this program?
+// 6
// b) How many function calls are there?
+// 1
// c) Using documentation, explain what the expression movieLength % 60 represents
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
+// % is the modulos operator, movieLength % 60 gives us the remainder, essentially we divide 60 by movieLenght and return the remainder
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
+/* we are subtracting remainingSeconds from movieLength, remainingSeconds is a variable that holds the result from totalMinutes % 60,
+the expression in brackets will evaluate first and then the result divided by 60.
+*/
// e) What do you think the variable result represents? Can you think of a better name for this variable?
-
+//runTime
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
+/* I have experimented with different values by changing the movieLength variable, and they all work, it works because we have
+didn't hardcode our expressions and used variables.
+*/
+
From 20eeeeaa05c3f6217611b713236ca86795b7bcbb Mon Sep 17 00:00:00 2001
From: d-odumosu
Date: Fri, 19 Jun 2026 21:09:04 +0100
Subject: [PATCH 12/12] answered all questions in 3-to-pounds.js
---
Sprint-1/3-mandatory-interpret/3-to-pounds.js | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js
index 60c9ace69a..c5e6651ed7 100644
--- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js
+++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js
@@ -6,6 +6,7 @@ const penceStringWithoutTrailingP = penceString.substring(
);
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
+
const pounds = paddedPenceNumberString.substring(
0,
paddedPenceNumberString.length - 2
@@ -25,3 +26,16 @@ console.log(`£${pounds}.${pence}`);
// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"
+// 3. we are declaring a variable and assigning it the variable penceString which holds the value "399p" but without the p - the method .subString is used
+// here to remove the p.
+// 8. we are declaring a variable and assigning it the variable penceStringWithoutTrailingP which holds the value "399
+// we are then using the .padStart method, however the method will not make any change because we have passed in the argument 3 which i
+// is the total length the string should be after padding - our string is already 3 lengths long.
+// 10. we are using a substring to slice our string from the first index to paddedPenceNumberString.length - 2, paddedPenceNumberString.length
+// will give us the number 3, so paddedPenceNumberString.length - 2 also means 3 - 2 which gives us 1, so from index 0 which is 3 to index 1 which is exclusive.
+// 15. we are declaring a variable pence and assigning it the variable paddedPenceNumberString which holds the result of a couple
+// method chains, firstly a .substring method with the argument "paddedPenceNumberString.length - 2" which also means 3 - 2, so it will
+// slice from index 1 to the end as we have not given a second argument, then we follow with a padEnd, this time we are adding
+// characters to the end of the string - we want a total of two characters
+//19. we use a string template to console log
+