From 919f2bc98ed14fbe0e885c590675ec9e35c80ade Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 13 Sep 2026 12:51:12 +0100 Subject: [PATCH 01/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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/75] 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 6b3261199f0a3cd65d6b641774b533dc120adaf4 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 22:41:47 +0100 Subject: [PATCH 55/75] task 1.js mandatory error completed --- Sprint-3/2-mandatory-debug/1.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..800cf59a7 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,21 @@ // Predict and explain first... // =============> write your prediction here +// Code will not work because the paremeters should be on same line as return -function sum(a, b) { - return; - a + b; -} +// function sum(a, b) { +// return; +// a + b; +// } -console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); +// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +// The errors in this codes is the semi-colon in front of the return and the placeholder parameters not on same line as the return // Finally, correct the code to fix the problem // =============> write your new code here + +function sum(a, b) { + return a + b; +} + +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); From e6d47e5e4c4d38214d7d9421f278283198abc1f8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Tue, 22 Sep 2026 23:06:46 +0100 Subject: [PATCH 56/75] task 2.js mandatory debug completed --- Sprint-3/2-mandatory-debug/2.js | 36 ++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..4d79d3906 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -2,23 +2,45 @@ // Predict the output of the following code: // =============> Write your prediction here +// Answer below: +// There is a constant variable num with value 103, the code should print last digit of the constant variable. -const num = 103; +// const num = 103; -function getLastDigit() { - return num.toString().slice(-1); -} +// function getLastDigit() { +// return num.toString().slice(-1); +// } -console.log(`The last digit of 42 is ${getLastDigit(42)}`); -console.log(`The last digit of 105 is ${getLastDigit(105)}`); -console.log(`The last digit of 806 is ${getLastDigit(806)}`); +// console.log(`The last digit of 42 is ${getLastDigit(42)}`); +// console.log(`The last digit of 105 is ${getLastDigit(105)}`); +// console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction // =============> write the output here +// Answer below: +// The last digit of 42 is 3 +// The last digit of 105 is 3 +// The last digit of 806 is 3 + + // Explain why the output is the way it is // =============> write your explanation here +// Answer below: +// The code kept repeating same value for all log because of the constant variable decleared before the function and used inside the function. + // Finally, correct the code to fix the problem // =============> write your new code here +function getLastDigit(num) { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); + + // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem +// The global constant variable outside the function has affected the code and caused it to always reference the last number of the global variable +// To fix this, the global variable will be removed from code and the function getLastDigit should take the variable name "num" assigned to the global variable. From 4eb2cc6eeeb2b71870cc3aabb63e4a316a529add Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 23 Sep 2026 17:08:23 +0100 Subject: [PATCH 57/75] BMI task completed --- Sprint-3/3-mandatory-implement/1-bmi.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..414bf1d74 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,5 +15,8 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { + bmi = weight / (height * height) + return bmi.toFixed(1) // return the BMI of someone based off their weight and height } +console.log(`Your BMI is ${calculateBMI(100, 1.62)}`) From 712ef52637f600d3de6ba9d5b8f42982c58b7c57 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 23 Sep 2026 17:10:40 +0100 Subject: [PATCH 58/75] Add explanation for getLastDigit function issue and correction --- Sprint-3/2-mandatory-debug/2.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 4d79d3906..e760e4c2f 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -42,5 +42,8 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem + +// Answer below: + // The global constant variable outside the function has affected the code and caused it to always reference the last number of the global variable // To fix this, the global variable will be removed from code and the function getLastDigit should take the variable name "num" assigned to the global variable. From 25fdf9bfbcbb3fa602ce3dcd639384c23673c222 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 23 Sep 2026 17:21:46 +0100 Subject: [PATCH 59/75] cases task completed --- Sprint-3/3-mandatory-implement/2-cases.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..37dc9e33b 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,9 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase + +function upperCase(str) { + returnUpperCase = str.toUpperCase().replaceAll(" ", "_") + return returnUpperCase +} +console.log(upperCase("my name is mathew")) \ No newline at end of file From 24751a8f64bc23626d4cfb40c8afd73d7de648aa Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 23 Sep 2026 17:23:16 +0100 Subject: [PATCH 60/75] cases task completed --- Sprint-3/3-mandatory-implement/2-cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 37dc9e33b..7668ae3b9 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -19,4 +19,4 @@ function upperCase(str) { returnUpperCase = str.toUpperCase().replaceAll(" ", "_") return returnUpperCase } -console.log(upperCase("my name is mathew")) \ No newline at end of file +console.log(upperCase("what is your name mr man? ")) \ No newline at end of file From 4929bf8f1be9251633a6475e1becc4b718320747 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 23 Sep 2026 20:06:37 +0100 Subject: [PATCH 61/75] task 3-to-pounds completed --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 10754da73..7d1824309 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,43 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs + + +// const penceString = "399p"; + +// const penceStringWithoutTrailingP = penceString.substring( +// 0, +// penceString.length - 1 +// ); + +// const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +// const pounds = paddedPenceNumberString.substring( +// 0, +// paddedPenceNumberString.length - 2 +// ); + +// const pence = paddedPenceNumberString +// .substring(paddedPenceNumberString.length - 2) +// .padEnd(2, "0"); + +// console.log(`£${pounds}.${pence}`); + + +function toPounds(inPounds) { + const penceStringWithoutTrailingP = inPounds.substring( + 0, + inPounds.length - 1 +); + +const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 +); + +const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); +return `£${pounds}.${pence}`; +} +console.log(toPounds("599554p")) \ No newline at end of file From 1b7b0d73b5a7f36b4fb5f5ac40b21e0d6c853176 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Wed, 23 Sep 2026 23:07:03 +0100 Subject: [PATCH 62/75] task 4 time format completed --- Sprint-3/4-mandatory-interpret/time-format.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..58c1dc52b 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -1,11 +1,15 @@ function pad(num) { + // console.log(num) let numString = num.toString(); + // console.log(numString, "numstr") while (numString.length < 2) { numString = "0" + numString; } + // console.log(numString, "FULLNUM") return numString; } + function formatTimeDisplay(seconds) { const remainingSeconds = seconds % 60; const totalMinutes = (seconds - remainingSeconds) / 60; @@ -14,6 +18,10 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } +console.log(formatTimeDisplay(61)) + + + // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions @@ -21,18 +29,27 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// =============> write your answer here +// Answer below: +// Pad runs once for "totalHours", once "remainingMinutes" and once for "remainingSeconds" in total pad is called 3 times. // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// =============> write your answer here +// Answer below: +// The first pad is pad(totalHours) and the value is 0 // c) What is the return value of pad when it is called for the first time? // =============> write your answer here +// The value is 0 plus the "0" added to it to make the value 00 // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> write your answer here +// Answer below: +// The last call is pad(remainingSeconds) and the value is 1 // e) What is the return value of pad when it is called for the last time in this program? Explain your answer -// =============> write your answer here +// =============> write your answer here +// Answer below: +// the return value initially is 1 and "0" was added to it in front to make the value 01 From e09db2b35e3ec0c5db6a6f13469cb91a8e40baa0 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 13:58:25 +0100 Subject: [PATCH 63/75] testing for bugs --- Sprint-3/5-stretch-extend/format-time.js | 78 ++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..8da600125 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -8,18 +8,84 @@ function formatAs12HourClock(time) { return `${hours - 12}:00 pm`; } return `${time} am`; -} +} +// console.log(formatAs12HourClock("10:15")); -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; +// Early Morning: ================> assertion passed +let currentOutput = formatAs12HourClock("08:30"); +let targetOutput = "08:30 am"; console.assert( currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` + `current output: ${currentOutput}, target output: ${targetOutput}` ); +console.log(formatAs12HourClock("08:30")) -const currentOutput2 = formatAs12HourClock("23:00"); -const targetOutput2 = "11:00 pm"; +// Mid-morning ==============> assertion passed +currentOutput = formatAs12HourClock("10:00"); +targetOutput = "10:00 am"; +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +); +console.log(formatAs12HourClock("10.00")) + +// Late morning ============> assertion passed +currentOutput = formatAs12HourClock("11:45"); +targetOutput = "11:45 am"; +console.assert( + currentOutput === targetOutput, + `current output: ${currentOutput}, target output: ${targetOutput}` +); +console.log(formatAs12HourClock("11.45")) + + +// Afternoon =============> assertion failed +let currentOutput2 = formatAs12HourClock("12:00"); +let targetOutput2 = "12:00 pm"; console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); +console.log(formatAs12HourClock("12:00")) + +// Early afternoon =============> assertion passed +currentOutput2 = formatAs12HourClock("14:00"); +targetOutput2 = "02:00 pm"; +console.assert( + currentOutput2 === targetOutput2, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); +console.log(formatAs12HourClock("14:00")) + +// Mid afternoon =============> time display doesn't correspond +currentOutput2 = formatAs12HourClock("15:30"); +targetOutput2 = "03:30 pm"; +console.assert( + currentOutput2 === targetOutput2, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); +console.log(formatAs12HourClock("15:30")) + +// Towards evening ==============> time display doesn't correspond +currentOutput2 = formatAs12HourClock("17:30"); +targetOutput2 = "05:30 pm"; +console.assert( + currentOutput2 === targetOutput2, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); +console.log(formatAs12HourClock("17:30")) + +// Late night =============> assertion passed +currentOutput2 = formatAs12HourClock("23:00"); +targetOutput2 = "11:00 pm"; +console.assert( + currentOutput2 === targetOutput2, + `current output: ${currentOutput2}, target output: ${targetOutput2}` +); +console.log(formatAs12HourClock("23:00")) + + + + + + From 004cb3bd14feedf2294ffebde46d2876814c9009 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 14:14:09 +0100 Subject: [PATCH 64/75] Minutes solved --- Sprint-3/5-stretch-extend/format-time.js | 90 +++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 8da600125..41843a5e6 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -2,10 +2,94 @@ // Make sure to do the prep before you do the coursework // Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find. +// function formatAs12HourClock(time) { +// const hours = Number(time.slice(0, 2)); +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } +// // console.log(formatAs12HourClock("10:15")); + +// // Early Morning: ================> assertion passed +// let currentOutput = formatAs12HourClock("08:30"); +// let targetOutput = "08:30 am"; +// console.assert( +// currentOutput === targetOutput, +// `current output: ${currentOutput}, target output: ${targetOutput}` +// ); +// console.log(formatAs12HourClock("08:30")) + +// // Mid-morning ==============> assertion passed +// currentOutput = formatAs12HourClock("10:00"); +// targetOutput = "10:00 am"; +// console.assert( +// currentOutput === targetOutput, +// `current output: ${currentOutput}, target output: ${targetOutput}` +// ); +// console.log(formatAs12HourClock("10.00")) + +// // Late morning ============> assertion passed +// currentOutput = formatAs12HourClock("11:45"); +// targetOutput = "11:45 am"; +// console.assert( +// currentOutput === targetOutput, +// `current output: ${currentOutput}, target output: ${targetOutput}` +// ); +// console.log(formatAs12HourClock("11.45")) + + +// // Afternoon =============> assertion failed +// let currentOutput2 = formatAs12HourClock("12:00"); +// let targetOutput2 = "12:00 pm"; +// console.assert( +// currentOutput2 === targetOutput2, +// `current output: ${currentOutput2}, target output: ${targetOutput2}` +// ); +// console.log(formatAs12HourClock("12:00")) + +// // Early afternoon =============> assertion passed +// currentOutput2 = formatAs12HourClock("14:00"); +// targetOutput2 = "02:00 pm"; +// console.assert( +// currentOutput2 === targetOutput2, +// `current output: ${currentOutput2}, target output: ${targetOutput2}` +// ); +// console.log(formatAs12HourClock("14:00")) + +// // Mid afternoon =============> time display doesn't correspond +// currentOutput2 = formatAs12HourClock("15:30"); +// targetOutput2 = "03:30 pm"; +// console.assert( +// currentOutput2 === targetOutput2, +// `current output: ${currentOutput2}, target output: ${targetOutput2}` +// ); +// console.log(formatAs12HourClock("15:30")) + +// // Towards evening ==============> time display doesn't correspond +// currentOutput2 = formatAs12HourClock("17:30"); +// targetOutput2 = "05:30 pm"; +// console.assert( +// currentOutput2 === targetOutput2, +// `current output: ${currentOutput2}, target output: ${targetOutput2}` +// ); +// console.log(formatAs12HourClock("17:30")) + +// // Late night =============> assertion passed +// currentOutput2 = formatAs12HourClock("23:00"); +// targetOutput2 = "11:00 pm"; +// console.assert( +// currentOutput2 === targetOutput2, +// `current output: ${currentOutput2}, target output: ${targetOutput2}` +// ); +// console.log(formatAs12HourClock("23:00")) + + function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = time.slice(3, 5); if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${hours - 12}:${minute} pm`; } return `${time} am`; } @@ -89,3 +173,7 @@ console.log(formatAs12HourClock("23:00")) + + + + From 9224cf2d696429a411d589377a6120c4f7491ac0 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 15:07:10 +0100 Subject: [PATCH 65/75] bug fixed --- Sprint-3/5-stretch-extend/format-time.js | 99 ++++++------------------ 1 file changed, 25 insertions(+), 74 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 41843a5e6..043d89a8a 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -85,95 +85,46 @@ // console.log(formatAs12HourClock("23:00")) +// Test result: +// Hours and Minutes worked in the AM function for different time test. +// 12:00 in the afternoon doesn't function correctly +// 00:00 mid-night doesnt work +// Minutes in the PM are not working. + +// To fix bug: + function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); const minutes = time.slice(3, 5); + + if (hours === 0) { + return `12:${minutes} am` + } + if (hours === 12) { + return `12:${minutes} pm`; + } if (hours > 12) { - return `${hours - 12}:${minute} pm`; + return `${hours - 12}:${minutes} pm`; } - return `${time} am`; -} -// console.log(formatAs12HourClock("10:15")); + -// Early Morning: ================> assertion passed -let currentOutput = formatAs12HourClock("08:30"); -let targetOutput = "08:30 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); -console.log(formatAs12HourClock("08:30")) - -// Mid-morning ==============> assertion passed -currentOutput = formatAs12HourClock("10:00"); -targetOutput = "10:00 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); -console.log(formatAs12HourClock("10.00")) + return `${time} am`; +} -// Late morning ============> assertion passed -currentOutput = formatAs12HourClock("11:45"); -targetOutput = "11:45 am"; +const currentOutput = formatAs12HourClock("00:00"); +const targetOutput = "12:00 am"; console.assert( currentOutput === targetOutput, `current output: ${currentOutput}, target output: ${targetOutput}` ); -console.log(formatAs12HourClock("11.45")) +console.log(formatAs12HourClock("00:00")) +const currentOutput2 = formatAs12HourClock("12:00"); +const targetOutput2 = "12:00 pm"; -// Afternoon =============> assertion failed -let currentOutput2 = formatAs12HourClock("12:00"); -let targetOutput2 = "12:00 pm"; console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); -console.log(formatAs12HourClock("12:00")) - -// Early afternoon =============> assertion passed -currentOutput2 = formatAs12HourClock("14:00"); -targetOutput2 = "02:00 pm"; -console.assert( - currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` -); -console.log(formatAs12HourClock("14:00")) - -// Mid afternoon =============> time display doesn't correspond -currentOutput2 = formatAs12HourClock("15:30"); -targetOutput2 = "03:30 pm"; -console.assert( - currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` -); -console.log(formatAs12HourClock("15:30")) - -// Towards evening ==============> time display doesn't correspond -currentOutput2 = formatAs12HourClock("17:30"); -targetOutput2 = "05:30 pm"; -console.assert( - currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` -); -console.log(formatAs12HourClock("17:30")) - -// Late night =============> assertion passed -currentOutput2 = formatAs12HourClock("23:00"); -targetOutput2 = "11:00 pm"; -console.assert( - currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` -); -console.log(formatAs12HourClock("23:00")) - - - - - - - - - +console.log(formatAs12HourClock("12:00")); \ No newline at end of file From 263727a5fd11f7cc2c138d6c6957b687756318ce Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 17:48:12 +0100 Subject: [PATCH 66/75] format-time.js task completed --- Sprint-3/5-stretch-extend/format-time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 043d89a8a..1d9da4f50 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -127,4 +127,4 @@ console.assert( `current output: ${currentOutput2}, target output: ${targetOutput2}` ); -console.log(formatAs12HourClock("12:00")); \ No newline at end of file +console.log(formatAs12HourClock("12:00")); From ae004f10096fe022dce231cfd20f55cf356fe5cb Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 18:09:54 +0100 Subject: [PATCH 67/75] task completed --- Sprint-3/5-stretch-extend/format-time.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 1d9da4f50..d7a71c282 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -111,20 +111,20 @@ function formatAs12HourClock(time) { return `${time} am`; } -const currentOutput = formatAs12HourClock("00:00"); -const targetOutput = "12:00 am"; +const currentOutput = formatAs12HourClock("01:00"); +const targetOutput = "01:00 am"; console.assert( currentOutput === targetOutput, `current output: ${currentOutput}, target output: ${targetOutput}` ); -console.log(formatAs12HourClock("00:00")) +console.log(formatAs12HourClock("01:00")) -const currentOutput2 = formatAs12HourClock("12:00"); -const targetOutput2 = "12:00 pm"; +const currentOutput2 = formatAs12HourClock("19:30"); +const targetOutput2 = "7:30 pm"; console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); -console.log(formatAs12HourClock("12:00")); +console.log(formatAs12HourClock("19:30")); From 877edfa616c31eb5d4a31185bab004642b16b16f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 19:43:10 +0100 Subject: [PATCH 68/75] Remove prep, password checker and function parameters --- 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 af338111ebcda64d2201ed38a627fc2808edd4d9 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 20:10:26 +0100 Subject: [PATCH 69/75] Fix multiplication parameters in console.log output --- Sprint-3/2-mandatory-debug/0.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index ae7cbd650..eac26ab1e 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -22,4 +22,4 @@ function multiply(a, b) { return a * b } -console.log(`The result of multiplying 10 and 32 is ${multiply(10, 10)}`); +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); From 336821f4da0566efd9842411f0f02daf7da5d2fe Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 20:26:51 +0100 Subject: [PATCH 70/75] Fix variable declaration in upperCase function --- Sprint-3/3-mandatory-implement/2-cases.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 7668ae3b9..b404d1ea0 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -16,7 +16,7 @@ // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase function upperCase(str) { - returnUpperCase = str.toUpperCase().replaceAll(" ", "_") + const returnUpperCase = str.toUpperCase().replaceAll(" ", "_") return returnUpperCase } console.log(upperCase("what is your name mr man? ")) \ No newline at end of file From e4821c0d2a868cfd3a2a867e76d01bf0f40b1890 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 20:27:12 +0100 Subject: [PATCH 71/75] Fix variable declaration in calculateBMI function --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 414bf1d74..4b6398b12 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -15,7 +15,7 @@ // It should return a string of their Body Mass Index to 1 decimal place function calculateBMI(weight, height) { - bmi = weight / (height * height) + const bmi = weight / (height * height) return bmi.toFixed(1) // return the BMI of someone based off their weight and height } From 45567172537d3750858feae86f0bde92ae37e347 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 20:28:45 +0100 Subject: [PATCH 72/75] Fix console.log output in toPounds function --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/3-mandatory-implement/3-to-pounds.js b/Sprint-3/3-mandatory-implement/3-to-pounds.js index 7d1824309..2ca524252 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -43,4 +43,4 @@ const pence = paddedPenceNumberString .padEnd(2, "0"); return `£${pounds}.${pence}`; } -console.log(toPounds("599554p")) \ No newline at end of file +console.log(toPounds("599p")) \ No newline at end of file From 534fc0c7b65a1f3784c728fc3113c08baf0eda5b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 20:42:55 +0100 Subject: [PATCH 73/75] Fix syntax errors and improve function implementations in various files --- Sprint-3/1-key-errors/1.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index e18e83407..6f0b04f61 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -2,13 +2,13 @@ // 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 +// A syntax error will occur for two reasons, first because there variable const "decimalNumber" being redecleared +// The second reason is because the function "convertToPercentage" is not called correctly. // =============> 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 +// Also because the console.log(decimalNumber) is just a name that exist inside the function // Try playing computer with the example to work out what is going on @@ -22,6 +22,10 @@ // console.log(decimalNumber); // =============> write your explanation here +// Answer: + +// const decimalNumber redeclares the parameter name which causes a SyntaxError. +// also console.log(decimalNumber) outside fails because the parameter only exists inside the function" // Finally, correct the code to fix the problem // =============> write your new code here From 9fdc5ceeae8c5565c84a93ae6fd0608c87d80505 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 20:49:05 +0100 Subject: [PATCH 74/75] Fix comments to clarify function behavior in multiply function --- Sprint-3/2-mandatory-debug/0.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index eac26ab1e..9216f69ec 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -13,8 +13,7 @@ // =============> 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 +// The original logs the product instead of returning it, so the function call inside the template string gives undefined // Finally, correct the code to fix the problem // =============> write your new code here From bcf8265baed540030411043a7ae54dec1e763e21 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 24 Sep 2026 23:07:59 +0100 Subject: [PATCH 75/75] Refactor getLastDigit function to accept a parameter and add new password checker functionality --- Sprint-3/2-mandatory-debug/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index e760e4c2f..4571f53fa 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -46,4 +46,4 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Answer below: // The global constant variable outside the function has affected the code and caused it to always reference the last number of the global variable -// To fix this, the global variable will be removed from code and the function getLastDigit should take the variable name "num" assigned to the global variable. +// To fix this, getLastDigit needed its own parameter, so num comes from whatever you pass in \ No newline at end of file