From 919f2bc98ed14fbe0e885c590675ec9e35c80ade Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 13 Sep 2026 12:51:12 +0100 Subject: [PATCH 01/68] Hello_World JavaScript file created --- Sprint-2/Prep/Hello_World.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Sprint-2/Prep/Hello_World.js diff --git a/Sprint-2/Prep/Hello_World.js b/Sprint-2/Prep/Hello_World.js new file mode 100644 index 000000000..e69de29bb From f93c281ccd02b5e6260e682167f58cc93b4a3be4 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 16 Sep 2026 22:41:23 +0100 Subject: [PATCH 02/68] restore password.js to prep --- Sprint-2/Prep/facts.js | 2 ++ Sprint-2/Prep/greeting.js | 34 ++++++++++++++++++++++++++++++++++ Sprint-2/Prep/password.js | 16 ++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 Sprint-2/Prep/facts.js create mode 100644 Sprint-2/Prep/greeting.js create mode 100644 Sprint-2/Prep/password.js diff --git a/Sprint-2/Prep/facts.js b/Sprint-2/Prep/facts.js new file mode 100644 index 000000000..01f81f418 --- /dev/null +++ b/Sprint-2/Prep/facts.js @@ -0,0 +1,2 @@ +console.log("One fact i love about git is that it allows people to collaborate on projects"); + diff --git a/Sprint-2/Prep/greeting.js b/Sprint-2/Prep/greeting.js new file mode 100644 index 000000000..c41f3aee1 --- /dev/null +++ b/Sprint-2/Prep/greeting.js @@ -0,0 +1,34 @@ +const greeting = "Hello There !"; +console.log(greeting); + +const name = "Matt"; +console.log(`${greeting}, I am ${name}`); + +let location = "Manchester"; +console.log(`${greeting}, my name is ${name} and i live in ${location} `); + +let location2 = "London"; +console.log(`${greeting}, I am ${name}, I will be traveling to ${location2} soon`); + +console.log("Dog" === "Mango"); + +console.log(5 + 15 === 20); + +console.log("dog" == "dog"); + +console.log(40+5 == "45"); + +console.log(60+40 > 50); + +console.log(100<= 90); + + + + + + + + + + + diff --git a/Sprint-2/Prep/password.js b/Sprint-2/Prep/password.js new file mode 100644 index 000000000..cf6d59c07 --- /dev/null +++ b/Sprint-2/Prep/password.js @@ -0,0 +1,16 @@ +const password = "Matt123"; +const userInput = "Anything"; +const administrator = "Anything"; +let response = " "; + +if (password === userInput) { + response = "Login successful"; +} else if (userInput === administrator) { + response = "Welcome to the site"; +} +else { + response = "Please try again"; +} +console.log(response); + + From 9f085a59464e1858698120f92e8381e26acab9ae Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 16 Sep 2026 22:58:46 +0100 Subject: [PATCH 03/68] 1-count.js completed --- Sprint-2/1-key-exercises/1-count.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..f0dfd3d3a 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -2,5 +2,4 @@ let count = 0; 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 has been able to reassign the value of the count variable from 0 to 1. The operator = assign the new value to be stored as 1. \ No newline at end of file From 0194cb3fab8db7fd9095262eea56908539fefa5f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 08:21:18 +0100 Subject: [PATCH 04/68] initials.js task completed --- Sprint-2/1-key-exercises/2-initials.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 964c9563c..46c126832 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -1,10 +1,7 @@ const firstName = "Creola"; const middleName = "Katherine"; const lastName = "Johnson"; +const initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; -// 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. +console.log(initials); -const initials = ``; - -// https://www.google.com/search?q=get+first+character+of+string+mdn From 6c5a8c87e2f4d972b244bb32b7feccb95e358883 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 10:15:35 +0100 Subject: [PATCH 05/68] file path task completed --- Sprint-2/1-key-exercises/3-paths.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ab90ebb28..f02c658f8 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/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}`); +onsole.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(0, lastSlashIndex); +console.log(dir) + +const ext = base.slice(4); +console.log(ext) // https://www.google.com/search?q=slice+mdn \ No newline at end of file From b1dcb1c5b96dab331e81e3b7515211888b6a1338 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:19:25 +0100 Subject: [PATCH 06/68] 4-random task completed --- Sprint-2/1-key-exercises/4-random.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..1d1a20868 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -2,8 +2,11 @@ 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 + +// num variable that carries the result of the expressions evaluated. +// (maximum - minimum) does basic math: 100 - 1 + 1 = 100 +// Math.floor() takes out all decimal and make them an integer. +// Math.random() gives random numbers between 0 and 100. +// + minimum add 1 at the end but randomise to the value between 0 and 100 \ No newline at end of file From aed6985d871b516f2a693ee96fa50ebb3caadbe2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:28:49 +0100 Subject: [PATCH 07/68] 0.js error fixed --- Sprint-2/2-mandatory-errors/0.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..7936eb7b5 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,2 +1,4 @@ -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? + +// This is solved by commenting the lines using ("//") \ No newline at end of file From dd027fa7ed20bf17be4ea0c0807dd2437a5b6809 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:31:06 +0100 Subject: [PATCH 08/68] add ; to lines --- Sprint-2/2-mandatory-errors/1.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..6a97b63cc 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -2,3 +2,4 @@ const age = 33; age = age + 1; +console.log(age); \ No newline at end of file From 3e2a1d2e8e455aaa80dcf25fb00a66127da58ad0 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:32:30 +0100 Subject: [PATCH 09/68] add ; to lines --- Sprint-2/1-key-exercises/4-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 1d1a20868..bf58fafae 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -2,7 +2,7 @@ const minimum = 1; const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; -console.log(num) +console.log(num); // num variable that carries the result of the expressions evaluated. From b1660fd2dc293e5bd41e083cb5b426e3c7d59281 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:32:42 +0100 Subject: [PATCH 10/68] add ; to lines --- Sprint-2/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index f02c658f8..35bab686f 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -18,9 +18,9 @@ onsole.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the ext part of the variable const dir = filePath.slice(0, lastSlashIndex); -console.log(dir) +console.log(dir); const ext = base.slice(4); -console.log(ext) +console.log(ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From ed261ff6083480151ae2ae88960e01a4f35a23e1 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:34:41 +0100 Subject: [PATCH 11/68] task 1.js completed --- Sprint-2/2-mandatory-errors/1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 6a97b63cc..8c5e17a24 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,5 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; age = age + 1; console.log(age); \ No newline at end of file From 5031f8f4166dbd4b699be875cf357ad767da10af Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 11:36:51 +0100 Subject: [PATCH 12/68] task 2.js completed --- Sprint-2/2-mandatory-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..2865eb8a4 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,5 +1,5 @@ // 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}`); From ddc8ba6e601f42f7c8c8d54ac5caa82bc2cc4bce Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 12:02:00 +0100 Subject: [PATCH 13/68] 3.js task completed --- Sprint-2/2-mandatory-errors/3.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..b1e37487b 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,9 +1,9 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); +console.log(last4Digits) -// The last4Digits variable should store the last 4 digits of cardNumber -// However, the code isn't working -// Before running the code, make and explain a prediction about why the code won't work -// 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 +// The variable cardNumber is not a string and the slice() function works with strings or array + +// Consider: Why does it give this error? +// It gave that error brcause the slice() tool are not applicable to numbers. +// I wasn't sure what error to expect because I'm just starting to learn the slice() tool From 8c577d5b9837c4d610a3da1375b2fe6c108305d1 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 12:05:52 +0100 Subject: [PATCH 14/68] task 4.js completed --- Sprint-2/2-mandatory-errors/4.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..6d9c264ef 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,3 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const HourClockTime1 = "8:53pm"; +const hourClockTime2 = "20:53"; +console.log(`${HourClockTime1}, ${hourClockTime2}`) From e44ee665b1b6ca29e0d715d99442fdb40f4ef785 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 12:36:12 +0100 Subject: [PATCH 15/68] percentage-change.js task completed --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..8b5298ea5 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/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; @@ -13,10 +13,19 @@ console.log(`The percentage change is ${percentageChange}`); // a) How many function calls are there in this file? Write down all the lines where a function call is made +// Answer: Line 4 'Number(), replaceAll()', line 5 'Number(), replaceAll()' and line 8, 100 + // 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? +// Answer: The error is coming from line 5, spotting at the Number(priceAfterOneYear.replaceAll("," "")); +// // It's a synthax error missing a comma // c) Identify all the lines that are variable reassignment statements +// Answer: Line 4 and 5 are variable assignment statements + // d) Identify all the lines that are variable declarations +// Answer: Line 1,2,7 and 8 are variable declearations + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// Answer: ReplaceAll() function clears out all the commas in the strings, the number() converts the strings to numbers to help with calculation From 48b94e2f43674e5af2d2b65ccc0f2a196a821412 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 17 Sep 2026 20:38:57 +0100 Subject: [PATCH 16/68] completed task 2-time-format --- .../3-mandatory-interpret/1-percentage-change.js | 3 ++- Sprint-2/3-mandatory-interpret/2-time-format.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 8b5298ea5..175115b87 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -17,7 +17,7 @@ console.log(`The percentage change is ${percentageChange}`); // 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? // Answer: The error is coming from line 5, spotting at the Number(priceAfterOneYear.replaceAll("," "")); -// // It's a synthax error missing a comma +// It's a synthax error missing a comma // c) Identify all the lines that are variable reassignment statements @@ -28,4 +28,5 @@ console.log(`The percentage change is ${percentageChange}`); // Answer: Line 1,2,7 and 8 are variable declearations // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? + // Answer: ReplaceAll() function clears out all the commas in the strings, the number() converts the strings to numbers to help with calculation diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 47d239558..7746b58e7 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -13,13 +13,27 @@ console.log(result); // a) How many variable declarations are there in this program? +// Answer: There is only 6 variable declearation altogether in this program + // b) How many function calls are there? +// Answer: There is only 1 call function in this program + // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +// Answer: The % symbol represent the remainder (modulo) operator, it calculates the leftover/remainder after integer division. +// Answer: % 60 divides the movieLength by 60 and returns only the remainder. + // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// Answer: Line 4 expression helps to eliminate any remainder from the equation, so its left with a clean multiple of 60 to avoid any decimal + // e) What do you think the variable result represents? Can you think of a better name for this variable? +// Answer: It represent the total duration of the movie formatted into hours, minutes and seconds +// Answer: A better name could be "totalMovieDuration" + // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer + +// Answer: It will work for integer values and will give us clear and clean result using this code. However, the result would not be clean as this using float values From 509ff8435d1e284c5d7705ab54d7eae0e937cdf0 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 11:53:52 +0100 Subject: [PATCH 17/68] explained task 0.js --- Sprint-2/2-mandatory-errors/0.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index 7936eb7b5..d5de77529 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,4 +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? -// This is solved by commenting the lines using ("//") \ No newline at end of file + +// This error is a syntaxError because javaScript could not understand the text. The error can be solved by commenting the lines using ("//") \ No newline at end of file From f80c15b985647ead657dd77abfea5f649c7fb7dc Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 12:00:03 +0100 Subject: [PATCH 18/68] task 1.js explained --- Sprint-2/2-mandatory-errors/1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 8c5e17a24..455d2f3ae 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -2,4 +2,7 @@ let age = 33; age = age + 1; -console.log(age); \ No newline at end of file +console.log(age); + +// This code returns a "TypeError: Assignment to constant variable.", because the variable age has been made constant and can't be manipulated. +// To solve the problem, we have to reassign the age variable from "const" to "let", that way it will allow for further manipulation and solve the error. \ No newline at end of file From 7d0d970d01f67b94472f795c4d98c72b80f22e98 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 12:10:33 +0100 Subject: [PATCH 19/68] task 2.js explained --- Sprint-2/2-mandatory-errors/2.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index 2865eb8a4..be5e8e8c1 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -3,3 +3,7 @@ const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); + + +// In this task, the variable was not assigned before attempting to print. Therefore, it gives the error "ReferenceError: Cannot access 'cityOfBirth' before initialization" +// The solution would be to assign the variable "cityOfBirth" first before printing the code. \ No newline at end of file From 5b4ed9d3fc15bdbfa7a806c91a43a60a87aa6000 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 12:21:19 +0100 Subject: [PATCH 20/68] task 3.js explained and completed --- Sprint-2/2-mandatory-errors/3.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index b1e37487b..2f163ffd5 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -5,5 +5,4 @@ console.log(last4Digits) // The variable cardNumber is not a string and the slice() function works with strings or array // Consider: Why does it give this error? -// It gave that error brcause the slice() tool are not applicable to numbers. -// I wasn't sure what error to expect because I'm just starting to learn the slice() tool +// It gave that error "TypeError: cardNumber.slice is not a function" brcause the slice() function tool are not applicable to numbers. From c41aa67de179641572efb5c08090654cf1bb80c2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 12:46:01 +0100 Subject: [PATCH 21/68] task 4.js completed and explained --- Sprint-2/2-mandatory-errors/4.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 6d9c264ef..52110e8cf 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,3 +1,6 @@ const HourClockTime1 = "8:53pm"; const hourClockTime2 = "20:53"; console.log(`${HourClockTime1}, ${hourClockTime2}`) + +// The code displayed the error "SyntaxError: Invalid or unexpected token", this is because javaScript does not understand the variable name format. +// This error is solved by renaming the variable name starting it with an alphabet and avoiding starting the variable with a number. From 08af9b8603e2381660b884af2a49bdeffaa50bad Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 12:53:26 +0100 Subject: [PATCH 22/68] completed and printed task 1-count.js --- Sprint-2/1-key-exercises/1-count.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index f0dfd3d3a..fd85be739 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -1,5 +1,6 @@ let count = 0; count = count + 1; +console.log(count) // Line 3 has been able to reassign the value of the count variable from 0 to 1. The operator = assign the new value to be stored as 1. \ No newline at end of file From 536761cb1bc730621a282ed96365dd99725f786e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 13:37:04 +0100 Subject: [PATCH 23/68] task 1-percentage-change explained --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 175115b87..94eed36ef 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/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; @@ -13,11 +13,14 @@ console.log(`The percentage change is ${percentageChange}`); // a) How many function calls are there in this file? Write down all the lines where a function call is made -// Answer: Line 4 'Number(), replaceAll()', line 5 'Number(), replaceAll()' and line 8, 100 +// Answer: Line 4 has 2 function call :'Number(), replaceAll()'. +// Line 5 has 2 function call: 'Number(), replaceAll()'. +// Line 10 has 1 function call console.log() +// In total there are 5 function calls. // 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? // Answer: The error is coming from line 5, spotting at the Number(priceAfterOneYear.replaceAll("," "")); -// It's a synthax error missing a comma +// It's a "SyntaxError: missing ) after argument list", missing a comma inside the replaceAll.() function. // c) Identify all the lines that are variable reassignment statements From 276f457261fe435d8c1ad405c553a9b0b170247d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 13:42:06 +0100 Subject: [PATCH 24/68] task 2-time-format.js explained and completed --- Sprint-2/3-mandatory-interpret/2-time-format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 7746b58e7..c730783ce 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -17,7 +17,7 @@ console.log(result); // b) How many function calls are there? -// Answer: There is only 1 call function in this program +// Answer: There is only 1 call function in this program console.log() // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators From 4aa0e25165c1c5c908153e7393f153be92dfd65b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 15:19:58 +0100 Subject: [PATCH 25/68] 3-to-pounds --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..a43ae9eac 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,34 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" + +// Answers: In line 1, a variable "penceString" was created holding the value "399p" +// In line 3-6, Another variable "penceStringWithoutTrailingP" was created to remove the trainling "p". +// That is, taking off the "p" in '399p' leaving it at just "399". + +// Line 3-6 used the function substring(0, penceString.lrength - 1) to cut out the "p" in the "penceString" variable. +// By starting count fron 0 (beginnning) of "399p". +// "Using penceString.lenght - 1" to check the length of the value in the variable penceString = "399p" (4), +// And deducting 1 from the value (399p - 1) leaving the value at "399" + +// Line 8 a variable "paddedPenceNumberString" was created and a function padStart(3, "0") +// was used to ensure the value of the variable remains at 3 and to be filled with "0" at the beginning if the value is less 3 + +// Line 9-12 created a variable "pounds" and used the subString(0, paddedPenceNumberString.length - 2 ) +// to start count from 0 of the "penceStringWithoutTrailingP" value which is 399. +// It further removed the last two number in the value by checking the length of the value with "paddedPenceNumberString.length" +// And subtracting 2 (399 - 2), cutting out 99 and leaving the value to remain 3. + +// Line 14-16 created a variable "pence", using the subString(paddedPenceNumberString.length - 2) +// to check the length of the value of the variable "paddedPenceNumberString" which remain 399 from line 8 +// The "substring(paddedPenceNumberString.length - 2)" function deducts 3 leaving the last two numbers 99 +// PadEnd(2, "0") ensure the value remains 2 and 0 to be added to value less than 2. +// However, we already have in our "pence" variable at a value of 2 numbers "99" + +// Line 18 printed our codes a formatted style adding the pound sign "£" + + + + + + From 4cc01f5b6eac4abfa325101a3dd397f9fd29c902 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 18 Sep 2026 22:32:22 +0100 Subject: [PATCH 26/68] interpreted task 3-to-pounds.js --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index a43ae9eac..c798b315a 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -27,13 +27,14 @@ console.log(`£${pounds}.${pence}`); // 1. const penceString = "399p": initialises a string variable with the value "399p" // Answers: In line 1, a variable "penceString" was created holding the value "399p" + // In line 3-6, Another variable "penceStringWithoutTrailingP" was created to remove the trainling "p". // That is, taking off the "p" in '399p' leaving it at just "399". -// Line 3-6 used the function substring(0, penceString.lrength - 1) to cut out the "p" in the "penceString" variable. +// Also, line 3-6 used the function substring(0, penceString.lrength - 1) to cut out the "p" in the "penceString" variable. // By starting count fron 0 (beginnning) of "399p". // "Using penceString.lenght - 1" to check the length of the value in the variable penceString = "399p" (4), -// And deducting 1 from the value (399p - 1) leaving the value at "399" +// And deducting 1 from the value (4 - 1), because length - 1 subtract 1 from the character/value count 4. leaving the value at "399" // Line 8 a variable "paddedPenceNumberString" was created and a function padStart(3, "0") // was used to ensure the value of the variable remains at 3 and to be filled with "0" at the beginning if the value is less 3 @@ -41,7 +42,7 @@ console.log(`£${pounds}.${pence}`); // Line 9-12 created a variable "pounds" and used the subString(0, paddedPenceNumberString.length - 2 ) // to start count from 0 of the "penceStringWithoutTrailingP" value which is 399. // It further removed the last two number in the value by checking the length of the value with "paddedPenceNumberString.length" -// And subtracting 2 (399 - 2), cutting out 99 and leaving the value to remain 3. +// And subtracting 2 (3 - 2), because length - 2 subtract 2 from the character/value count. Cutting out 99 and leaving the value to remain 3. // Line 14-16 created a variable "pence", using the subString(paddedPenceNumberString.length - 2) // to check the length of the value of the variable "paddedPenceNumberString" which remain 399 from line 8 From 0a50eb55c2c38a7c739b8e7a02943910f21c139c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 19 Sep 2026 10:11:15 +0100 Subject: [PATCH 27/68] fix: correct console log messages for base and dir parts in 3-paths.js --- Sprint-2/1-key-exercises/3-paths.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 35bab686f..ece5c41d3 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -12,13 +12,13 @@ const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; const lastSlashIndex = filePath.lastIndexOf("/"); const base = filePath.slice(lastSlashIndex + 1); -onsole.log(`The base part of ${filePath} is ${base}`); +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 = filePath.slice(0, lastSlashIndex); -console.log(dir); +console.log(`The dir part of ${filePath} is ${dir}`); const ext = base.slice(4); console.log(ext); From ae41a8e9c05f064a92f85f5b133166d1bba763c6 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 19 Sep 2026 10:12:46 +0100 Subject: [PATCH 28/68] fix: update console log for ext part in 3-paths.js --- Sprint-2/1-key-exercises/3-paths.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ece5c41d3..f6883e775 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -21,6 +21,6 @@ const dir = filePath.slice(0, lastSlashIndex); console.log(`The dir part of ${filePath} is ${dir}`); const ext = base.slice(4); -console.log(ext); +console.log(`The ext part of ${filePath} is ${ext}`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From a896a164726135e8647604f07797221879c92381 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 19 Sep 2026 15:01:03 +0100 Subject: [PATCH 29/68] task 1-kkey-exercise completed --- Sprint-2/1-key-exercises/3-paths.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index f6883e775..7b6d6b9c4 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -23,4 +23,5 @@ console.log(`The dir part of ${filePath} is ${dir}`); const ext = base.slice(4); console.log(`The ext part of ${filePath} is ${ext}`); + // https://www.google.com/search?q=slice+mdn \ No newline at end of file From b5bda0554e76d137491c5760489782706172a17e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 15:17:36 +0100 Subject: [PATCH 30/68] print file purposes --- Sprint-2/Prep/functions.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Sprint-2/Prep/functions.js diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js new file mode 100644 index 000000000..2c4ffe5ab --- /dev/null +++ b/Sprint-2/Prep/functions.js @@ -0,0 +1,16 @@ +console.log("In this exercise I will be learning different functions, and preactising them. ") + +// let userName = "Matthew" +// let location = "Manchester" +// let favoriteFood = "Jollof rice" + +// function myInfo(userName, location, favoriteFood) { +// console.log(`My name is ${userName}` ) +// console.log(`I live in ${location}` ) +// console.log(`My favorite food is ${favoriteFood}` ) +// } +// myInfo(userName, location, favoriteFood) + +// sliceUserName = userName.slice(0, 4) +// console.log(`My friends love to call me ${sliceUserName}`) + From aedbcb2e0d7c79ebd4a483256f71161822a550b3 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 15:18:56 +0100 Subject: [PATCH 31/68] created variables for personal information --- Sprint-2/Prep/functions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 2c4ffe5ab..18556a27c 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -1,8 +1,8 @@ console.log("In this exercise I will be learning different functions, and preactising them. ") -// let userName = "Matthew" -// let location = "Manchester" -// let favoriteFood = "Jollof rice" +let userName = "Matthew" +let location = "Manchester" +let favoriteFood = "Jollof rice" // function myInfo(userName, location, favoriteFood) { // console.log(`My name is ${userName}` ) From 655c50e7e3bd656f1051addbf53121133b8ada79 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 15:20:10 +0100 Subject: [PATCH 32/68] use function and parameters --- Sprint-2/Prep/functions.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 18556a27c..534582552 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -4,12 +4,12 @@ let userName = "Matthew" let location = "Manchester" let favoriteFood = "Jollof rice" -// function myInfo(userName, location, favoriteFood) { -// console.log(`My name is ${userName}` ) -// console.log(`I live in ${location}` ) -// console.log(`My favorite food is ${favoriteFood}` ) -// } -// myInfo(userName, location, favoriteFood) +function myInfo(userName, location, favoriteFood) { + console.log(`My name is ${userName}` ) + console.log(`I live in ${location}` ) + console.log(`My favorite food is ${favoriteFood}` ) +} +myInfo(userName, location, favoriteFood) // sliceUserName = userName.slice(0, 4) // console.log(`My friends love to call me ${sliceUserName}`) From 276400a8d94e2b682644eb7a69c3a7d64b892f2f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 15:20:54 +0100 Subject: [PATCH 33/68] practice slice function --- Sprint-2/Prep/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 534582552..9d1d031ad 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -11,6 +11,6 @@ function myInfo(userName, location, favoriteFood) { } myInfo(userName, location, favoriteFood) -// sliceUserName = userName.slice(0, 4) -// console.log(`My friends love to call me ${sliceUserName}`) +sliceUserName = userName.slice(0, 4) +console.log(`My friends love to call me ${sliceUserName}`) From c778acbc66c0793efdea05d2937956e693dba2cf Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 15:37:22 +0100 Subject: [PATCH 34/68] practice number functions --- Sprint-2/Prep/functions.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 9d1d031ad..3aabc0fe8 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -14,3 +14,10 @@ myInfo(userName, location, favoriteFood) sliceUserName = userName.slice(0, 4) console.log(`My friends love to call me ${sliceUserName}`) +sliceLocation = location.lastIndexOf("h") +console.log(sliceLocation) + +const number1 = "50" +const number2 = "100" +const result = Number(number1) + Number(number2) +console.log(result) From 69717b17c30d305fae5c83ea3bde3d358dba55c7 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 16:01:22 +0100 Subject: [PATCH 35/68] practice substring function --- Sprint-2/Prep/functions.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 3aabc0fe8..c261bbef7 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -21,3 +21,10 @@ const number1 = "50" const number2 = "100" const result = Number(number1) + Number(number2) console.log(result) + +let hobby = "I love football and traveling" +let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking") +console.log(moreHobby) + +const passion = hobby.substring(0, 15) +console.log(passion) From 9edf1ffd7b456308c8bbfd103177d08f8f4895e2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 16:05:49 +0100 Subject: [PATCH 36/68] more substring practice --- Sprint-2/Prep/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index c261bbef7..cb60e9a58 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -26,5 +26,5 @@ let hobby = "I love football and traveling" let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking") console.log(moreHobby) -const passion = hobby.substring(0, 15) +const passion = hobby.substring(6, 15) console.log(passion) From dba1c5eacb800ea4a7d7f2f6747794db072a90d8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 16:13:02 +0100 Subject: [PATCH 37/68] padstart function --- Sprint-2/Prep/functions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index cb60e9a58..82b90850f 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -28,3 +28,7 @@ console.log(moreHobby) const passion = hobby.substring(6, 15) console.log(passion) + +const luckyNumber = "7" +const changeNumber = luckyNumber.padStart(5, "0") +console.log(changeNumber) \ No newline at end of file From d8c40774663b150dfc02ebd77c925544fd22308a Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 16:15:28 +0100 Subject: [PATCH 38/68] padEnd practice --- Sprint-2/Prep/functions.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 82b90850f..9d17ed1a1 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -31,4 +31,7 @@ console.log(passion) const luckyNumber = "7" const changeNumber = luckyNumber.padStart(5, "0") -console.log(changeNumber) \ No newline at end of file +console.log(changeNumber) + +const anotherNumber = luckyNumber.padEnd(5, "0") +console.log(anotherNumber) \ No newline at end of file From 90cadbae9fab9d62c9cd07e2c760b2e22ced6085 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 20:54:30 +0100 Subject: [PATCH 39/68] Math.floor & Math.random practice --- Sprint-2/Prep/functions.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 9d17ed1a1..19bd6801e 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -34,4 +34,14 @@ const changeNumber = luckyNumber.padStart(5, "0") console.log(changeNumber) const anotherNumber = luckyNumber.padEnd(5, "0") -console.log(anotherNumber) \ No newline at end of file +console.log(anotherNumber) + +const carPrice = 30000.50 +const updatedCarPrice = Math.floor(carPrice) +console.log(updatedCarPrice) + +const addNumber = 20 +const addNumber2 = 30 +const addNumber3 = addNumber + addNumber2 +const addNumberResult = Math.random() * addNumber3 +console.log(addNumberResult) \ No newline at end of file From 903b731a96ce427f317cfe97912eb6c0d93056dd Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 21:09:37 +0100 Subject: [PATCH 40/68] lastIndexOf() function exercise --- Sprint-2/Prep/functions.js | 66 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index 19bd6801e..ab5db45a2 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -1,47 +1,51 @@ -console.log("In this exercise I will be learning different functions, and preactising them. ") +console.log("In this exercise I will be learning different functions, and preactising them. "); -let userName = "Matthew" -let location = "Manchester" -let favoriteFood = "Jollof rice" +let userName = "Matthew"; +let location = "Manchester"; +let favoriteFood = "Jollof rice"; function myInfo(userName, location, favoriteFood) { console.log(`My name is ${userName}` ) console.log(`I live in ${location}` ) console.log(`My favorite food is ${favoriteFood}` ) -} -myInfo(userName, location, favoriteFood) +}; +myInfo(userName, location, favoriteFood); -sliceUserName = userName.slice(0, 4) -console.log(`My friends love to call me ${sliceUserName}`) +sliceUserName = userName.slice(0, 4); +console.log(`My friends love to call me ${sliceUserName}`); -sliceLocation = location.lastIndexOf("h") -console.log(sliceLocation) +sliceLocation = location.lastIndexOf("h"); +console.log(sliceLocation); -const number1 = "50" -const number2 = "100" -const result = Number(number1) + Number(number2) -console.log(result) +const number1 = "50"; +const number2 = "100"; +const result = Number(number1) + Number(number2); +console.log(result); -let hobby = "I love football and traveling" -let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking") -console.log(moreHobby) +let hobby = "I love football and traveling"; +let moreHobby = hobby.replaceAll("football", "swiming").replaceAll("traveling", "hiking"); +console.log(moreHobby); -const passion = hobby.substring(6, 15) -console.log(passion) +const passion = hobby.substring(6, 15); +console.log(passion); -const luckyNumber = "7" -const changeNumber = luckyNumber.padStart(5, "0") -console.log(changeNumber) +const luckyNumber = "7"; +const changeNumber = luckyNumber.padStart(5, "0"); +console.log(changeNumber); -const anotherNumber = luckyNumber.padEnd(5, "0") -console.log(anotherNumber) +const anotherNumber = luckyNumber.padEnd(5, "0"); +console.log(anotherNumber); -const carPrice = 30000.50 -const updatedCarPrice = Math.floor(carPrice) -console.log(updatedCarPrice) +const carPrice = 30000.50; +const updatedCarPrice = Math.floor(carPrice); +console.log(updatedCarPrice); -const addNumber = 20 -const addNumber2 = 30 -const addNumber3 = addNumber + addNumber2 +const addNumber = 20; +const addNumber2 = 30; +const addNumber3 = addNumber + addNumber2; const addNumberResult = Math.random() * addNumber3 -console.log(addNumberResult) \ No newline at end of file +console.log(addNumberResult); + +const repeatedText = "one, two, three"; +const lastOnePosition = repeatedText.lastIndexOf("one"); +console.log(lastOnePosition); \ No newline at end of file From 3be5165598e124e1ca9d197259000bed7d5beb2f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 20 Sep 2026 21:34:31 +0100 Subject: [PATCH 41/68] completed --- Sprint-2/Prep/functions.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Sprint-2/Prep/functions.js b/Sprint-2/Prep/functions.js index ab5db45a2..3d7029f20 100644 --- a/Sprint-2/Prep/functions.js +++ b/Sprint-2/Prep/functions.js @@ -48,4 +48,19 @@ console.log(addNumberResult); const repeatedText = "one, two, three"; const lastOnePosition = repeatedText.lastIndexOf("one"); -console.log(lastOnePosition); \ No newline at end of file +console.log(lastOnePosition); + +// const yourName = prompt("Please enter your name: "); +// const yourLocation = prompt("Please enter your location: "); +// const yourHobby = prompt("Enter your hobby: "); +// const yourFavoriteFood = prompt("Please enter your favorite food: ") + +// function userInfo(yourName, yourLocation, yourHobby, yourFavoriteFood) { +// console.log(`Your name is ${yourName}`) +// console.log(`You live in ${yourLocation}`) +// console.log(`Your hobby is ${yourHobby}`) +// console.log(`Your favorite food is ${yourFavoriteFood}`) +// } + +// userInfo(yourName, yourLocation, yourHobby, yourFavoriteFood) +// Chrome devOps prompt function, variable and parameters From aade124509f168300d73f426ad47d90e2fdc6e56 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 12:39:11 +0100 Subject: [PATCH 42/68] Math.round task --- Sprint-3/prep | 1 + 1 file changed, 1 insertion(+) create mode 100644 Sprint-3/prep diff --git a/Sprint-3/prep b/Sprint-3/prep new file mode 100644 index 000000000..fad17d6a9 --- /dev/null +++ b/Sprint-3/prep @@ -0,0 +1 @@ +console.log(Math.round) \ No newline at end of file From 239699eeb1bd2acf67b201356cb765b939206a24 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 13:17:07 +0100 Subject: [PATCH 43/68] Math.round function task --- Sprint-3/passwordCheckerFunction.js | 0 Sprint-3/prep | 8 +++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 Sprint-3/passwordCheckerFunction.js diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js new file mode 100644 index 000000000..e69de29bb diff --git a/Sprint-3/prep b/Sprint-3/prep index fad17d6a9..6cc32539c 100644 --- a/Sprint-3/prep +++ b/Sprint-3/prep @@ -1 +1,7 @@ -console.log(Math.round) \ No newline at end of file +//console.log(Math.round(10.3)) + +const num1 = Math.round(10.3) +const num2 = Math.round(4.2) +const result = num1 + num2 +console.log(`Total sumation of the numbers is ${result}`) + From 3b45f5de8c06a394b85b3ceba75088fadbde964d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 13:59:50 +0100 Subject: [PATCH 44/68] password checker task --- Sprint-3/passwordCheckerFunction.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js index e69de29bb..0a27ba8e7 100644 --- a/Sprint-3/passwordCheckerFunction.js +++ b/Sprint-3/passwordCheckerFunction.js @@ -0,0 +1,20 @@ +// Already have the password stored in a variable +const password = "Mattcarolus10" + +// Receive the value which the user entered +function checkPassword(userInput) { + +// Compare the two values +if (userInput===password) { + +// If they match print "Correct password entered" + console.log("Correct password entered ") +} + +else { +// If they don't match print "Incorrect password, please try again" + console.log("Incorrect password, please try again") +} + +} +checkPassword("Mattcarolus") From 91b22a212b0a396d72c4126f8af0776a2fe1f9ce Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 14:39:58 +0100 Subject: [PATCH 45/68] password checker variable scope --- Sprint-3/passwordCheckerFunction.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js index 0a27ba8e7..fe8f9d3ba 100644 --- a/Sprint-3/passwordCheckerFunction.js +++ b/Sprint-3/passwordCheckerFunction.js @@ -1,20 +1,21 @@ -// Already have the password stored in a variable -const password = "Mattcarolus10" +// Already have the password stored in a variable; +const password = "Mattcarolus10"; -// Receive the value which the user entered +// Receive the value which the user entered; function checkPassword(userInput) { -// Compare the two values +// Compare the two values; if (userInput===password) { -// If they match print "Correct password entered" - console.log("Correct password entered ") +// If they match print "Correct password entered"; + response = "Correct password entered " } else { -// If they don't match print "Incorrect password, please try again" - console.log("Incorrect password, please try again") -} +// If they don't match print "Incorrect password, please try again"; + response = "Incorrect password, please try again" +}; -} -checkPassword("Mattcarolus") +}; +checkPassword("Mattcarolus10"); +console.log(response) From 5b60bb179fc52a9ce0df73c96bd97087d02ae51d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 14:42:17 +0100 Subject: [PATCH 46/68] test wrong password --- Sprint-3/passwordCheckerFunction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js index fe8f9d3ba..3c1a39595 100644 --- a/Sprint-3/passwordCheckerFunction.js +++ b/Sprint-3/passwordCheckerFunction.js @@ -17,5 +17,5 @@ else { }; }; -checkPassword("Mattcarolus10"); +checkPassword("Mattcarolus"); console.log(response) From d10542b3569e34c520b68f33603bb9d6766a2a6c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 15:53:32 +0100 Subject: [PATCH 47/68] return exercise completed --- Sprint-3/passwordCheckerFunction.js | 66 +++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js index 3c1a39595..f0ef38b8e 100644 --- a/Sprint-3/passwordCheckerFunction.js +++ b/Sprint-3/passwordCheckerFunction.js @@ -1,21 +1,71 @@ // Already have the password stored in a variable; -const password = "Mattcarolus10"; +// Exercise one: Using console.log and calling function +// const password = "Mattcarolus10"; + +// // Receive the value which the user entered; +// function checkPassword(userInput) { + +// // Compare the two values; +// if (userInput===password) { + +// // If they match print "Correct password entered"; +// console.log("Correct password entered ") +// } + +// else { +// // If they don't match print "Incorrect password, please try again"; +// console.log("Incorrect password, please try again") +// }; + +// }; +// checkPassword("Mattcarolus10"); + + + +// // Exercise 2: Using the variable scope "response" +// const password2 = "Mattcarolus10"; + +// // Receive the value which the user entered; +// function checkPassword(userInput) { + +// // Compare the two values; +// if (userInput===password2) { + +// // If they match print "Correct password entered"; +// response = "Correct password entered " +// } + +// else { +// // If they don't match print "Incorrect password, please try again"; +// response = "Incorrect password, please try again" +// }; + +// }; +// checkPassword("Mattcarolus"); +// console.log(response) + + + +const password3 = "Mattcarolus10"; +const output = checkPassword("Mattcarolus10"); // Receive the value which the user entered; function checkPassword(userInput) { + let response; // Compare the two values; -if (userInput===password) { +if (userInput===password3) { // If they match print "Correct password entered"; - response = "Correct password entered " + response = "Correct password entered "; } else { // If they don't match print "Incorrect password, please try again"; - response = "Incorrect password, please try again" -}; + response = "Incorrect password, please try again"; +} +return response; +} +console.log(output); + -}; -checkPassword("Mattcarolus"); -console.log(response) From 4793a566f206ff18d6d9720848c5784ea4e68b6e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 16:00:19 +0100 Subject: [PATCH 48/68] output and return exercise completed --- Sprint-3/passwordCheckerFunction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js index f0ef38b8e..4e3ab8020 100644 --- a/Sprint-3/passwordCheckerFunction.js +++ b/Sprint-3/passwordCheckerFunction.js @@ -45,7 +45,7 @@ // console.log(response) - +//Exercise 3: output and return const password3 = "Mattcarolus10"; const output = checkPassword("Mattcarolus10"); From 51e9adcd077c74d5dbaa1e9c8a62fb1f7c1db277 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Mon, 21 Sep 2026 19:19:04 +0100 Subject: [PATCH 49/68] parameters arguement function --- Sprint-3/function-parameters.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Sprint-3/function-parameters.js diff --git a/Sprint-3/function-parameters.js b/Sprint-3/function-parameters.js new file mode 100644 index 000000000..be3ac0fc3 --- /dev/null +++ b/Sprint-3/function-parameters.js @@ -0,0 +1,4 @@ +function greet(timeOfDay, name) { + console.log(`Good ${timeOfDay}, ${name}.`); +} +greet("afternoon", "Mathew") From bc34e0eafacd5ef01884666e1000e51a6584fcf1 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 19:10:50 +0100 Subject: [PATCH 50/68] 1-key-error task completed --- Sprint-3/1-key-errors/0.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..552419761 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,23 @@ // Predict and explain first... -// =============> write your prediction here +// ======> write your prediction here: I predict that the code should cut out, and make the first letter of the string an uppercase letter, +// then add every letters that comes after // 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: The error read "SyntaxError: Identifier 'str' has already been declared", +// this is as a result of having two variables with same name. The error occoured in this code because the variable "str" has been decleared twice -// =============> write your explanation here // =============> write your new code here + +function capitalise(str) { + let str2= `${str[0].toUpperCase()}${str.slice(1)}` + return str2; +} +console.log(capitalise("money")) \ No newline at end of file From 79db8a6468f495f7e0cae36decd09222a94f55d8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 20:57:20 +0100 Subject: [PATCH 51/68] task 1.js completed --- Sprint-3/1-key-errors/1.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..e18e83407 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,20 +1,34 @@ // Predict and explain first... // Why will an error occur when this program runs? -// =============> write your prediction here +// Answer below: +// An error will occur for two reasons, first because there variable "decimalNumber" being decleared +// The second reason is because the function "convertToPercentage" placeholder has no value when it was called -// Try playing computer with the example to work out what is going on +// =============> write your prediction here: +// Answer below: +// I predicted that the code will not work because of the variable (decimalNumber) inside the function, +// Also because the console.log function is not not calling the function "convertToPercentage" with a value -function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; - return percentage; -} +// Try playing computer with the example to work out what is going on + +// function convertToPercentage(decimalNumber) { +// const decimalNumber = 0.5; +// const percentage = `${decimalNumber * 100}%`; -console.log(decimalNumber); +// return percentage; +// } +// console.log(decimalNumber); // =============> write your explanation here // 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(10.5)); \ No newline at end of file From fb93c79135c8b8a2b93762f827abeedcda98ed37 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 21:32:44 +0100 Subject: [PATCH 52/68] task 2.js completed --- Sprint-3/1-key-errors/2.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..b662be303 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,20 +1,33 @@ // Predict and explain first BEFORE you run any code... +// Answer below: +// The code will not work because the placeholder variable (3) should be an actual name like "num" + // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here -function square(3) { - return num * num; -} +// function square(3) { +// return num * num; +// } + + // =============> write the error message here +// SyntaxError: Unexpected number // =============> explain this error message here +// The error message explains the error in the function parameter (3), the function expects a name parameter instead of a number. // Finally, correct the code to fix the problem // =============> write your new code here +function square(num) { + return num * num; +} +console.log(square(10)) + + From fb14e2c6fc057f9038c8ce95282a471922be13b2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 21:33:48 +0100 Subject: [PATCH 53/68] clear spaces --- Sprint-3/1-key-errors/2.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index b662be303..3c5f20756 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -12,8 +12,6 @@ // return num * num; // } - - // =============> write the error message here // SyntaxError: Unexpected number From 5839e8d79e4d3fe622d00887412fe5e64d3e4841 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 22:28:25 +0100 Subject: [PATCH 54/68] task mandatory-debug completed --- Sprint-3/2-mandatory-debug/0.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..ae7cbd650 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,25 @@ // Predict and explain first... +// Answer below: +// The code needs a value inside the console.log function to multiply, but no value was useed to replace the placeholder parameters +// It should be an error, no value to return // =============> write your prediction here -function multiply(a, b) { - console.log(a * b); -} +// 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 +// Answer below: +// The code has two function parameters, it prints the parameters without an actual value. To correct this code the console.log has to be replaced with retun +// To return the value of the parameters when 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, 10)}`); From 973eda42cd61459ebaba161d44141c1170d87d77 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 16:29:01 +0100 Subject: [PATCH 55/68] random.js task fixed --- Sprint-2/1-key-exercises/4-random.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index bf58fafae..b93494707 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -5,8 +5,8 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; console.log(num); -// num variable that carries the result of the expressions evaluated. -// (maximum - minimum) does basic math: 100 - 1 + 1 = 100 -// Math.floor() takes out all decimal and make them an integer. -// Math.random() gives random numbers between 0 and 100. -// + minimum add 1 at the end but randomise to the value between 0 and 100 \ No newline at end of file +// "num" variable carries the result/value of the expressions evaluated. +// (maximum - minimum) workout the size of the range: 100 - 1 + 1 = 100 +// Math.floor() takes out all decimal and make them a whole number from 0 to 99. +// Math.random() gives a decimal from 0 up to just under 1 (0.9999999). +// + minimum add 1 to the expression at the end because it is decleared a variable. \ No newline at end of file From e29ee814e96c20497a8004140f8cad1d4deb38c8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 16:32:44 +0100 Subject: [PATCH 56/68] variable names changed --- Sprint-2/2-mandatory-errors/4.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 52110e8cf..7021106f9 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,6 +1,6 @@ -const HourClockTime1 = "8:53pm"; -const hourClockTime2 = "20:53"; -console.log(`${HourClockTime1}, ${hourClockTime2}`) +const time12Hours = "8:53pm"; +const time24Hours = "20:53"; +console.log(`${time12Hours}, ${time24Hours}`) // The code displayed the error "SyntaxError: Invalid or unexpected token", this is because javaScript does not understand the variable name format. // This error is solved by renaming the variable name starting it with an alphabet and avoiding starting the variable with a number. From a6755669bbf7df3d1bef8758231ad4dc0d75cc6b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 16:37:53 +0100 Subject: [PATCH 57/68] number() fixed --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 94eed36ef..0416eab1a 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -32,4 +32,4 @@ console.log(`The percentage change is ${percentageChange}`); // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? -// Answer: ReplaceAll() function clears out all the commas in the strings, the number() converts the strings to numbers to help with calculation +// Answer: ReplaceAll() function clears out all the commas in the strings, the Number() converts the strings to numbers to help with calculation From 9cbdc83bcdf211d78e1e0f4a639e9068d7ea30d2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 16:47:00 +0100 Subject: [PATCH 58/68] rephrased comments --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index c798b315a..f2c1c6f61 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -31,10 +31,11 @@ console.log(`£${pounds}.${pence}`); // In line 3-6, Another variable "penceStringWithoutTrailingP" was created to remove the trainling "p". // That is, taking off the "p" in '399p' leaving it at just "399". -// Also, line 3-6 used the function substring(0, penceString.lrength - 1) to cut out the "p" in the "penceString" variable. -// By starting count fron 0 (beginnning) of "399p". -// "Using penceString.lenght - 1" to check the length of the value in the variable penceString = "399p" (4), -// And deducting 1 from the value (4 - 1), because length - 1 subtract 1 from the character/value count 4. leaving the value at "399" +// 3-6. substring(0, penceString.length - 1): +// the first argument is the start index, so 0 means the first character +// penceString.length is 4 because there are 4 characters, at indexes 0 to 3 +// the second argument is the end index and it is exclusive, it stops just before that position +// length - 1 is 3, so it stops before index 3, dropping the "p" and leaving "399" // Line 8 a variable "paddedPenceNumberString" was created and a function padStart(3, "0") // was used to ensure the value of the variable remains at 3 and to be filled with "0" at the beginning if the value is less 3 From a6c7eb16d670cfa99d539a4e71cb6bf20b02de00 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 18:00:21 +0100 Subject: [PATCH 59/68] restore Sprint-3 to upstream --- Sprint-3/1-key-errors/0.js | 22 ++++++---------------- Sprint-3/1-key-errors/1.js | 30 ++++++++---------------------- Sprint-3/1-key-errors/2.js | 17 +++-------------- Sprint-3/2-mandatory-debug/0.js | 19 ++++--------------- 4 files changed, 21 insertions(+), 67 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 552419761..653d6f5a0 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,23 +1,13 @@ // Predict and explain first... -// ======> write your prediction here: I predict that the code should cut out, and make the first letter of the string an uppercase letter, -// then add every letters that comes after +// =============> write your prediction here // 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; -// } - - -// =============> write your explanation here: The error read "SyntaxError: Identifier 'str' has already been declared", -// this is as a result of having two variables with same name. The error occoured in this code because the variable "str" has been decleared twice - -// =============> write your new code here - function capitalise(str) { - let str2= `${str[0].toUpperCase()}${str.slice(1)}` - return str2; + let str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; } -console.log(capitalise("money")) \ No newline at end of file + +// =============> write your explanation here +// =============> write your new code here diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index e18e83407..f2d56151f 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -1,34 +1,20 @@ // Predict and explain first... // Why will an error occur when this program runs? -// Answer below: -// An error will occur for two reasons, first because there variable "decimalNumber" being decleared -// The second reason is because the function "convertToPercentage" placeholder has no value when it was called - -// =============> write your prediction here: -// Answer below: -// I predicted that the code will not work because of the variable (decimalNumber) inside the function, -// Also because the console.log function is not not calling the function "convertToPercentage" with a value - +// =============> write your prediction here // Try playing computer with the example to work out what is going on -// function convertToPercentage(decimalNumber) { -// const decimalNumber = 0.5; -// const percentage = `${decimalNumber * 100}%`; +function convertToPercentage(decimalNumber) { + const decimalNumber = 0.5; + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} -// return percentage; -// } -// console.log(decimalNumber); +console.log(decimalNumber); // =============> write your explanation here // 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(10.5)); \ No newline at end of file diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index 3c5f20756..aad57f7cf 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -1,31 +1,20 @@ // Predict and explain first BEFORE you run any code... -// Answer below: -// The code will not work because the placeholder variable (3) should be an actual name like "num" - // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here -// function square(3) { -// return num * num; -// } +function square(3) { + return num * num; +} // =============> write the error message here -// SyntaxError: Unexpected number // =============> explain this error message here -// The error message explains the error in the function parameter (3), the function expects a name parameter instead of a number. // Finally, correct the code to fix the problem // =============> write your new code here -function square(num) { - return num * num; -} -console.log(square(10)) - - diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index ae7cbd650..b27511b41 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,25 +1,14 @@ // Predict and explain first... -// Answer below: -// The code needs a value inside the console.log function to multiply, but no value was useed to replace the placeholder parameters -// It should be an error, no value to return // =============> write your prediction here -// 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 -// Answer below: -// The code has two function parameters, it prints the parameters without an actual value. To correct this code the console.log has to be replaced with retun -// To return the value of the parameters when 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, 10)}`); From ca8e18f258b1450df032c549d80ee530c7ae267b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 18:05:25 +0100 Subject: [PATCH 60/68] remove untracked Sprint-3 files --- Sprint-3/function-parameters.js | 4 -- Sprint-3/passwordCheckerFunction.js | 71 ----------------------------- Sprint-3/prep | 7 --- 3 files changed, 82 deletions(-) delete mode 100644 Sprint-3/function-parameters.js delete mode 100644 Sprint-3/passwordCheckerFunction.js delete mode 100644 Sprint-3/prep diff --git a/Sprint-3/function-parameters.js b/Sprint-3/function-parameters.js deleted file mode 100644 index be3ac0fc3..000000000 --- a/Sprint-3/function-parameters.js +++ /dev/null @@ -1,4 +0,0 @@ -function greet(timeOfDay, name) { - console.log(`Good ${timeOfDay}, ${name}.`); -} -greet("afternoon", "Mathew") diff --git a/Sprint-3/passwordCheckerFunction.js b/Sprint-3/passwordCheckerFunction.js deleted file mode 100644 index 4e3ab8020..000000000 --- a/Sprint-3/passwordCheckerFunction.js +++ /dev/null @@ -1,71 +0,0 @@ -// Already have the password stored in a variable; -// Exercise one: Using console.log and calling function -// const password = "Mattcarolus10"; - -// // Receive the value which the user entered; -// function checkPassword(userInput) { - -// // Compare the two values; -// if (userInput===password) { - -// // If they match print "Correct password entered"; -// console.log("Correct password entered ") -// } - -// else { -// // If they don't match print "Incorrect password, please try again"; -// console.log("Incorrect password, please try again") -// }; - -// }; -// checkPassword("Mattcarolus10"); - - - -// // Exercise 2: Using the variable scope "response" -// const password2 = "Mattcarolus10"; - -// // Receive the value which the user entered; -// function checkPassword(userInput) { - -// // Compare the two values; -// if (userInput===password2) { - -// // If they match print "Correct password entered"; -// response = "Correct password entered " -// } - -// else { -// // If they don't match print "Incorrect password, please try again"; -// response = "Incorrect password, please try again" -// }; - -// }; -// checkPassword("Mattcarolus"); -// console.log(response) - - -//Exercise 3: output and return -const password3 = "Mattcarolus10"; -const output = checkPassword("Mattcarolus10"); - -// Receive the value which the user entered; -function checkPassword(userInput) { - let response; - -// Compare the two values; -if (userInput===password3) { - -// If they match print "Correct password entered"; - response = "Correct password entered "; -} - -else { -// If they don't match print "Incorrect password, please try again"; - response = "Incorrect password, please try again"; -} -return response; -} -console.log(output); - - diff --git a/Sprint-3/prep b/Sprint-3/prep deleted file mode 100644 index 6cc32539c..000000000 --- a/Sprint-3/prep +++ /dev/null @@ -1,7 +0,0 @@ -//console.log(Math.round(10.3)) - -const num1 = Math.round(10.3) -const num2 = Math.round(4.2) -const result = num1 + num2 -console.log(`Total sumation of the numbers is ${result}`) - From 3c63ee6ac92e915553f0e40d551db7dc6b31be36 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 19:24:30 +0100 Subject: [PATCH 61/68] path exercises fixed --- Sprint-2/1-key-exercises/3-paths.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 7b6d6b9c4..e01765d7f 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -20,7 +20,8 @@ console.log(`The base part of ${filePath} is ${base}`); const dir = filePath.slice(0, lastSlashIndex); console.log(`The dir part of ${filePath} is ${dir}`); -const ext = base.slice(4); +const lastDotIndex = base.lastIndexOf("."); +const ext = base.slice(lastDotIndex + 1); console.log(`The ext part of ${filePath} is ${ext}`); From a5df0de800e619682603a13a4db3fdac24d61f3a Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 19:34:11 +0100 Subject: [PATCH 62/68] comment rephrased on 3-to-pounds --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index f2c1c6f61..8b113cc09 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -28,17 +28,14 @@ console.log(`£${pounds}.${pence}`); // Answers: In line 1, a variable "penceString" was created holding the value "399p" -// In line 3-6, Another variable "penceStringWithoutTrailingP" was created to remove the trainling "p". -// That is, taking off the "p" in '399p' leaving it at just "399". - -// 3-6. substring(0, penceString.length - 1): +// 3-6. substring(0, penceString.length - 1): // the first argument is the start index, so 0 means the first character // penceString.length is 4 because there are 4 characters, at indexes 0 to 3 // the second argument is the end index and it is exclusive, it stops just before that position // length - 1 is 3, so it stops before index 3, dropping the "p" and leaving "399" -// Line 8 a variable "paddedPenceNumberString" was created and a function padStart(3, "0") -// was used to ensure the value of the variable remains at 3 and to be filled with "0" at the beginning if the value is less 3 +// 8. padStart(3, "0") pads the start until the string is at least 3 characters long +// "399" is already 3, so nothing gets added here // Line 9-12 created a variable "pounds" and used the subString(0, paddedPenceNumberString.length - 2 ) // to start count from 0 of the "penceStringWithoutTrailingP" value which is 399. From 31c3d988823d35bfaa2593a3a75423ab0fc5e55b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 19:43:08 +0100 Subject: [PATCH 63/68] correct spelling --- Sprint-2/2-mandatory-errors/3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index 2f163ffd5..deb62082f 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -5,4 +5,4 @@ console.log(last4Digits) // The variable cardNumber is not a string and the slice() function works with strings or array // Consider: Why does it give this error? -// It gave that error "TypeError: cardNumber.slice is not a function" brcause the slice() function tool are not applicable to numbers. +// It gave that error "TypeError: cardNumber.slice is not a function" because the slice() function tool are not applicable to numbers. From f214a57053f192b7f86d3c89d44f130ed2e0cd62 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 25 Sep 2026 20:06:43 +0100 Subject: [PATCH 64/68] pad time output to 2 digits --- Sprint-2/3-mandatory-interpret/2-time-format.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index c730783ce..c42149663 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = 3661; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -6,7 +6,7 @@ const totalMinutes = (movieLength - remainingSeconds) / 60; const remainingMinutes = totalMinutes % 60; const totalHours = (totalMinutes - remainingMinutes) / 60; -const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; +const result = `${String(totalHours).padStart(2, "0")}:${String(remainingMinutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`; console.log(result); // For the piece of code above, read the code and then answer the following questions From 8655d1736de2033885f8cb545b9989ed90bb6f30 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 27 Sep 2026 18:25:39 +0100 Subject: [PATCH 65/68] last dot index fixed --- Sprint-2/1-key-exercises/3-paths.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index e01765d7f..b96ffbdaa 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -21,7 +21,7 @@ const dir = filePath.slice(0, lastSlashIndex); console.log(`The dir part of ${filePath} is ${dir}`); const lastDotIndex = base.lastIndexOf("."); -const ext = base.slice(lastDotIndex + 1); +const ext = base.slice(lastDotIndex); console.log(`The ext part of ${filePath} is ${ext}`); From b593f3e8d5b8548011699efc654f774b81fc6ddd Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 27 Sep 2026 18:26:48 +0100 Subject: [PATCH 66/68] swap line 10 and 11 --- Sprint-2/1-key-exercises/4-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index b93494707..fef31689e 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -7,6 +7,6 @@ console.log(num); // "num" variable carries the result/value of the expressions evaluated. // (maximum - minimum) workout the size of the range: 100 - 1 + 1 = 100 -// Math.floor() takes out all decimal and make them a whole number from 0 to 99. // Math.random() gives a decimal from 0 up to just under 1 (0.9999999). +// Math.floor() takes out all decimal and make them a whole number from 0 to 99. // + minimum add 1 to the expression at the end because it is decleared a variable. \ No newline at end of file From 92a5450e77381bebb61932e37187e639f46be93f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 27 Sep 2026 18:36:47 +0100 Subject: [PATCH 67/68] rephrased + minimum interpret --- Sprint-2/1-key-exercises/4-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index fef31689e..305d279c8 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -9,4 +9,4 @@ console.log(num); // (maximum - minimum) workout the size of the range: 100 - 1 + 1 = 100 // Math.random() gives a decimal from 0 up to just under 1 (0.9999999). // Math.floor() takes out all decimal and make them a whole number from 0 to 99. -// + minimum add 1 to the expression at the end because it is decleared a variable. \ No newline at end of file +// + minimum shift 1 through 100 in the expression \ No newline at end of file From 8dfc043b09a56dc0a7f75fa23d9fb2584ca18a72 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 27 Sep 2026 18:43:50 +0100 Subject: [PATCH 68/68] line 47 - 48 rephrased --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 8b113cc09..841047f09 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -44,9 +44,9 @@ console.log(`£${pounds}.${pence}`); // Line 14-16 created a variable "pence", using the subString(paddedPenceNumberString.length - 2) // to check the length of the value of the variable "paddedPenceNumberString" which remain 399 from line 8 -// The "substring(paddedPenceNumberString.length - 2)" function deducts 3 leaving the last two numbers 99 -// PadEnd(2, "0") ensure the value remains 2 and 0 to be added to value less than 2. -// However, we already have in our "pence" variable at a value of 2 numbers "99" +// substring(length - 2) takes the last 2 characters of the padded value, giving us the pence (99) +// padEnd(2, "0") makes sure the value is at least 2 characters long, adding "0" if it is shorter +// in this case the pence value is already 2 characters ("99"), so padEnd adds nothing // Line 18 printed our codes a formatted style adding the pound sign "£"