From 4fdac8d231255375d438573dd085c36368717837 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Mon, 14 Sep 2026 23:32:12 +0200 Subject: [PATCH 01/41] Added hello_world and facts, Practiced console.log --- prep/facts.js | 1 + prep/hello_world.js | 1 + 2 files changed, 2 insertions(+) create mode 100644 prep/facts.js create mode 100644 prep/hello_world.js diff --git a/prep/facts.js b/prep/facts.js new file mode 100644 index 000000000..3fb02818c --- /dev/null +++ b/prep/facts.js @@ -0,0 +1 @@ +console.log("I love women"); \ No newline at end of file diff --git a/prep/hello_world.js b/prep/hello_world.js new file mode 100644 index 000000000..de8882976 --- /dev/null +++ b/prep/hello_world.js @@ -0,0 +1 @@ +console.log("Hello World!"); \ No newline at end of file From e9869635c9d93c30d655eea6e60ab1e4f2cef3e9 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 15 Sep 2026 11:58:05 +0200 Subject: [PATCH 02/41] Added file, decalred varible --- prep/greeting.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 prep/greeting.js diff --git a/prep/greeting.js b/prep/greeting.js new file mode 100644 index 000000000..e69de29bb From da52a82dc849f10041e7d0661d0b52bb350b1b23 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 15 Sep 2026 12:04:36 +0200 Subject: [PATCH 03/41] Added file, decalred varible --- prep/greeting.js | 1 + 1 file changed, 1 insertion(+) diff --git a/prep/greeting.js b/prep/greeting.js index e69de29bb..e1c6de568 100644 --- a/prep/greeting.js +++ b/prep/greeting.js @@ -0,0 +1 @@ +const greeting = "Hello you sexy sausage"; \ No newline at end of file From 21c137811fcdc459778af2248a2010cd3412660f Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 15 Sep 2026 14:33:02 +0200 Subject: [PATCH 04/41] practicing variables --- prep/greeting.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prep/greeting.js b/prep/greeting.js index e1c6de568..d3b231f29 100644 --- a/prep/greeting.js +++ b/prep/greeting.js @@ -1 +1,3 @@ -const greeting = "Hello you sexy sausage"; \ No newline at end of file +const greeting = "Hello you sexy sausage"; +const name = "Mommy"; +console.log(`${greeting}, ${name}`); \ No newline at end of file From 24565bc250ce527eceef5a14ce3a81160b52ca2e Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 15 Sep 2026 21:08:40 +0200 Subject: [PATCH 05/41] Practice comparing values --- prep/compare.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 prep/compare.js diff --git a/prep/compare.js b/prep/compare.js new file mode 100644 index 000000000..0794fc597 --- /dev/null +++ b/prep/compare.js @@ -0,0 +1,20 @@ +// 1 +hi = "hello" === "hello" +console.log(hi) +// true + +// 2 +low = "CYF" === "cyf" +console.log(low) +// false + +// 3 +const homeTown = "Newcastle" +homeTown === "Liverpool" +console.log(homeTown === "Liverpool") +// false + +// 4 +num = 42 === 42 +console.log(num) +// true \ No newline at end of file From 6aa92d27a7b60c2681a63a98f21b9c70824c1da8 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 15 Sep 2026 22:09:35 +0200 Subject: [PATCH 06/41] Practice if statement --- prep/condition.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 prep/condition.js diff --git a/prep/condition.js b/prep/condition.js new file mode 100644 index 000000000..2bce769bb --- /dev/null +++ b/prep/condition.js @@ -0,0 +1,3 @@ +if (4 == "4") { + console.log("ur mom") +} \ No newline at end of file From b49b6c946e34306fb83f34849f83e79bbfa9f80b Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 15 Sep 2026 23:05:04 +0200 Subject: [PATCH 07/41] Password checker task --- prep/passwordChecker.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 prep/passwordChecker.js diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js new file mode 100644 index 000000000..44241da53 --- /dev/null +++ b/prep/passwordChecker.js @@ -0,0 +1,11 @@ +const password = "secretword123"; +const userInput = "secretword123"; +const adminPassword = "override"; + +if (userInput === password){ + console.log("Correct password entered"); +} else if (userInput === adminPassword){ + console.log("Admin access granted") +} else{ + console.log("Incorrect password!"); +} \ No newline at end of file From dc179bb65d44e070ce381670b1d178946365e344 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 16 Sep 2026 14:46:19 +0200 Subject: [PATCH 08/41] Practice identifying and explaining errors --- prep/errors.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 prep/errors.js diff --git a/prep/errors.js b/prep/errors.js new file mode 100644 index 000000000..6273b7355 --- /dev/null +++ b/prep/errors.js @@ -0,0 +1,13 @@ +//const volunteer = "Shadi"; +//const volunteer = "Abdi"; + +// cant declare variable cause it is constant + +// const volunteer = "Shadi"; +// volunteer = "Hinde"; + +// cant declare variable cause it is constant + +// console.log(Math.round(10.3); + +// missing ) at end \ No newline at end of file From f77cdcecaa956821cdd851d4ccf4db91abeb3d58 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 16 Sep 2026 15:05:24 +0200 Subject: [PATCH 09/41] Explained variable reassignment. --- Sprint-2/1-key-exercises/1-count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..6cadfef2b 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -4,3 +4,5 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing + +// count is being increased each time the code runs by +1. = is basically just reassigning the value each time. From 1a46297ff7c9dd514287d69e6f08e1fd10b6dc40 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 16 Sep 2026 15:18:58 +0200 Subject: [PATCH 10/41] Getting the first char of a string --- Sprint-2/1-key-exercises/2-initials.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 964c9563c..45eef73ed 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,6 +5,12 @@ const lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -const initials = ``; +const firstChar = firstName.charAt(0); +const secondChar = middleName.charAt(0); +const thirdChar = lastName.charAt(0); + + +const initials = `${firstChar}${secondChar}${thirdChar}`; +console.log(initials) // https://www.google.com/search?q=get+first+character+of+string+mdn From c67e10a1ca4d96491b8425f17b557ed4f96b29c8 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 16 Sep 2026 15:39:46 +0200 Subject: [PATCH 11/41] Explain code exercise --- Sprint-2/1-key-exercises/4-random.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..76182687f 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -7,3 +7,11 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // 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 + +// Math.floor() - rounds down to nearest integer +// Math.random() - gives a random number +// (max - min + 1) - 100 +// simple bodmas bro + +// math.random = 2 +// num = 201 \ No newline at end of file From 8d45e6fa92b5743488fc4291f91abea37d3a3f3e Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 16 Sep 2026 15:49:15 +0200 Subject: [PATCH 12/41] Slice exercise --- Sprint-2/1-key-exercises/3-paths.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index ab90ebb28..e8e39ca58 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -17,7 +17,11 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the dir part of the filePath variable // Create a variable to store the ext part of the variable -const dir = ; -const ext = ; + + +const dir = filePath.slice(base, -9); +const ext = filePath.slice(-4); + +console.log(ext) // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 5125f877cf56a87ba86026d19183415fa414093d Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 13:21:05 +0200 Subject: [PATCH 13/41] Comment practice --- 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..a76715850 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? + +// Comment out lines with "//" \ No newline at end of file From d1b3b6313badf13a55b8ba5ad04bcdef9773f1f1 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 13:40:29 +0200 Subject: [PATCH 14/41] Var reassignment error handling --- Sprint-2/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..e03657d95 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,4 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; age = age + 1; +// changed const to let \ No newline at end of file From ec4411ec5082b9f12685033c5389ee148efbed5c Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 13:42:34 +0200 Subject: [PATCH 15/41] Assign var before print --- Sprint-2/2-mandatory-errors/2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..7f3af0111 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,5 +1,7 @@ // 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}`); + +// You must first assign the var before u try to print it \ No newline at end of file From aaecbb4a2a78c1b97c4d8822493bc025be558977 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 14:21:19 +0200 Subject: [PATCH 16/41] Splice works with strings not numbers --- Sprint-2/2-mandatory-errors/3.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..8173975fa 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,4 +1,4 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber @@ -7,3 +7,5 @@ const last4Digits = cardNumber.slice(-4); // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? // Then try updating the expression last4Digits is assigned to, in order to get the correct value +console.log(last4Digits) +// cardNumber was stored as a number, which does not work with .splice(). \ No newline at end of file From 6d0e108525f15c1845032a14edaf532872a74f34 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 14:23:10 +0200 Subject: [PATCH 17/41] Var name cannot start with a number --- 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..0d4f38e63 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 twelveHourClockTime = "8:53pm"; +const miliataryhourClockTime = "20:53"; +// variables cannot start with a number. \ No newline at end of file From 8e8a1474cb26ec88f8e733cc1d2e5471e46564c6 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 15:06:26 +0200 Subject: [PATCH 18/41] Answered questions --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..cbbbd953e 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -1,8 +1,8 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +carPrice = Number(carPrice.replaceAll("," "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; @@ -12,11 +12,16 @@ console.log(`The percentage change is ${percentageChange}`); // Read the code and then answer the questions below // a) How many function calls are there in this file? Write down all the lines where a function call is made +// Number() line 4,5. .replaceAll() line 4,5. console.log() line 10. // 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? +// line 5: put a comma between the find and replace // c) Identify all the lines that are variable reassignment statements +// line 4, 5. // d) Identify all the lines that are variable declarations +// line 1,2,7,8. // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// convert str to number type and find and replace commas with nothing so that the number is read correctly. \ No newline at end of file From dcb83129507109cc44b5711bc1cb545d1d1e0cc5 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 15:15:53 +0200 Subject: [PATCH 19/41] Added error back in --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index cbbbd953e..9ba2eae2d 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; From 0dfc659b459a2c51c15ec96df9b838c009306885 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 15:26:36 +0200 Subject: [PATCH 20/41] Answered questions --- Sprint-2/3-mandatory-interpret/2-time-format.js | 9 ++++++++- 1 file changed, 8 insertions(+), 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 47d239558..4a285e3b8 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = 2; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,14 +12,21 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? +// 6 // b) How many function calls are there? +// 1 // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +// its a rem calculation, basically taking how many groups of 60 are in the movie, the remaining sec is the result. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// (movieLength - remainingSeconds): will give us a whole number +// / 60: takes the whole number and converts it to minutes // e) What do you think the variable result represents? Can you think of a better name for this variable? +// the movie length in hours, minutes and seconds // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// edge case: negative movie length. For negative movie lengths it should print an error saying that movielength cannot be less than 0. \ No newline at end of file From e574bb5a4b93768cffe1e0d198cec65911909a3d Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 15:32:39 +0200 Subject: [PATCH 21/41] Answered questions --- Sprint-2/3-mandatory-interpret/2-time-format.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 4a285e3b8..b9752191a 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -19,14 +19,16 @@ console.log(result); // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators -// its a rem calculation, basically taking how many groups of 60 are in the movie, the remaining sec is the result. +// its a rem calculation, basically taking how many groups of 60 are in the movie, and giving back the remainder. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? -// (movieLength - remainingSeconds): will give us a whole number +// (movieLength - remainingSeconds): gives us a value that's an exact multiple of 60, so it divides evenly. // / 60: takes the whole number and converts it to minutes // e) What do you think the variable result represents? Can you think of a better name for this variable? -// the movie length in hours, minutes and seconds +// the movie length in hours, minutes and seconds. formattedDuration // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer -// edge case: negative movie length. For negative movie lengths it should print an error saying that movielength cannot be less than 0. \ No newline at end of file +// edge cases: negative movie length. For negative movie lengths it should print an error saying that movielength cannot be less than 0. +// : decimal numbers +// : should tell user that the unit is seconds From e339abea1d3f7af545d5eab33891c8cd7cd7ca25 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Thu, 17 Sep 2026 21:59:27 +0200 Subject: [PATCH 22/41] Explained what each step in the code does --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 7 +++++++ 1 file changed, 7 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..0435be1ff 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,10 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// 2. const penceStringWithoutTrailingP: from index 0, to length of string - 1 (4-1=3). (0,3) we get the string from index 0 to index 2 which removes the p at the end. +// 3. const paddedPenceNumberString: if length < 3, pad start of string with "0". since it is we just get 399. +// 4. const pounds: take string from index 0 to length of string - 2 (3-2=1). (0,1) we get the 1st index "3". +// 5. .substring(): length = 3. (3-2=1). (1,end of string). this gives us 99 +// 6. .padEnd(): if previous length of string < 2: pad end with "0" +// 7. console.log() basically just prints pounds and pence as the proper format (£"pound"."pence") using string literals +// NB: padding is for a safety measure if the inputs were shorter. \ No newline at end of file From 7d2bbe66672bec626629c15adc44832120a129ba Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Mon, 21 Sep 2026 11:55:02 +0200 Subject: [PATCH 23/41] Practice using chrome console --- Sprint-2/4-stretch-explore/chrome.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 962580b82..403640cd5 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -9,7 +9,23 @@ In the Chrome console, invoke the function `alert` with one argument, the string What effect does calling the `alert` function have? +// Alert brings a pop up window out and says "Hello world" from the page. It also has a button called "OK" + Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? What is the return value of `prompt`? + +// Opens a popup box with a text input. The value inside the () is what would display above the input. +// The return value is myname? + +This is the code I did. +alert("Hello world") +undefined +prompt("What is your name") +'Tylerluvslasagne' +let myname = prompt("what is yur name") +undefined +console.log(myname) +VM319:1 I LOVE MY EX +undefined \ No newline at end of file From 656d9653b7c1e009db8eea2d85c290c28ecc1e5f Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Mon, 21 Sep 2026 12:19:51 +0200 Subject: [PATCH 24/41] Learning objects in JS --- Sprint-2/4-stretch-explore/objects.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index 0216dee56..be8a79745 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -13,4 +13,18 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? +// Console is an object that stores properties as fucntions. (Think of import = math, math.sqrt(9)) + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +// It means that you are calling on console to run this particular function in your javascript code. +// console.log: access property(log) inside object(console). +// The . is the property access operator. +// The () contain an argument(s) which run the code. + +My code: +console.log + ƒ log() { [native code] } +console + console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} +typeof console + 'object' \ No newline at end of file From b492e0296bc6e63bef27006d568c06cac927c77c Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Mon, 21 Sep 2026 13:16:53 +0200 Subject: [PATCH 25/41] remove prep files from coursework branch --- prep/compare.js | 20 -------------------- prep/condition.js | 3 --- prep/errors.js | 13 ------------- prep/facts.js | 1 - prep/greeting.js | 3 --- prep/hello_world.js | 1 - prep/passwordChecker.js | 11 ----------- 7 files changed, 52 deletions(-) delete mode 100644 prep/compare.js delete mode 100644 prep/condition.js delete mode 100644 prep/errors.js delete mode 100644 prep/facts.js delete mode 100644 prep/greeting.js delete mode 100644 prep/hello_world.js delete mode 100644 prep/passwordChecker.js diff --git a/prep/compare.js b/prep/compare.js deleted file mode 100644 index 0794fc597..000000000 --- a/prep/compare.js +++ /dev/null @@ -1,20 +0,0 @@ -// 1 -hi = "hello" === "hello" -console.log(hi) -// true - -// 2 -low = "CYF" === "cyf" -console.log(low) -// false - -// 3 -const homeTown = "Newcastle" -homeTown === "Liverpool" -console.log(homeTown === "Liverpool") -// false - -// 4 -num = 42 === 42 -console.log(num) -// true \ No newline at end of file diff --git a/prep/condition.js b/prep/condition.js deleted file mode 100644 index 2bce769bb..000000000 --- a/prep/condition.js +++ /dev/null @@ -1,3 +0,0 @@ -if (4 == "4") { - console.log("ur mom") -} \ No newline at end of file diff --git a/prep/errors.js b/prep/errors.js deleted file mode 100644 index 6273b7355..000000000 --- a/prep/errors.js +++ /dev/null @@ -1,13 +0,0 @@ -//const volunteer = "Shadi"; -//const volunteer = "Abdi"; - -// cant declare variable cause it is constant - -// const volunteer = "Shadi"; -// volunteer = "Hinde"; - -// cant declare variable cause it is constant - -// console.log(Math.round(10.3); - -// missing ) at end \ No newline at end of file diff --git a/prep/facts.js b/prep/facts.js deleted file mode 100644 index 3fb02818c..000000000 --- a/prep/facts.js +++ /dev/null @@ -1 +0,0 @@ -console.log("I love women"); \ No newline at end of file diff --git a/prep/greeting.js b/prep/greeting.js deleted file mode 100644 index d3b231f29..000000000 --- a/prep/greeting.js +++ /dev/null @@ -1,3 +0,0 @@ -const greeting = "Hello you sexy sausage"; -const name = "Mommy"; -console.log(`${greeting}, ${name}`); \ No newline at end of file diff --git a/prep/hello_world.js b/prep/hello_world.js deleted file mode 100644 index de8882976..000000000 --- a/prep/hello_world.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello World!"); \ No newline at end of file diff --git a/prep/passwordChecker.js b/prep/passwordChecker.js deleted file mode 100644 index 44241da53..000000000 --- a/prep/passwordChecker.js +++ /dev/null @@ -1,11 +0,0 @@ -const password = "secretword123"; -const userInput = "secretword123"; -const adminPassword = "override"; - -if (userInput === password){ - console.log("Correct password entered"); -} else if (userInput === adminPassword){ - console.log("Admin access granted") -} else{ - console.log("Incorrect password!"); -} \ No newline at end of file From 42e81a75db36f2fe2ac1c27146a6ef3dd9dc9eb6 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 08:08:52 +0200 Subject: [PATCH 26/41] Replace all function fixed --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 9ba2eae2d..a1b00f2ea 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -1,8 +1,8 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; -carPrice = Number(carPrice.replaceAll("," "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +carPrice = Number(carPrice.replaceAll(",","")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",","")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; From bb1e2e036fbc4380d016f975206ab45381b4abb4 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 08:42:17 +0200 Subject: [PATCH 27/41] Fixed dir and ext calculation --- Sprint-2/1-key-exercises/3-paths.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index e8e39ca58..236293c94 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -19,9 +19,10 @@ console.log(`The base part of ${filePath} is ${base}`); -const dir = filePath.slice(base, -9); -const ext = filePath.slice(-4); +const dir = filePath.slice(0, lastSlashIndex); +const ext = filePath.slice(filePath.lastIndexOf("."), filePath.length); +console.log(dir) console.log(ext) // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 4fef4323a7107fba7af2f387f6568fa75fc078fc Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 08:43:38 +0200 Subject: [PATCH 28/41] Changed movielength to og value --- 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 b9752191a..b4c7035c9 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 2; // length of movie in seconds +const movieLength = 8784; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; From 5f75bcf7c92c64145abbe27403d856af5a1931ae Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 10:01:39 +0200 Subject: [PATCH 29/41] Predicted, explained and fixed the error --- Sprint-3/1-key-errors/0.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 653d6f5a0..50758c19e 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -1,13 +1,27 @@ // Predict and explain first... // =============> write your prediction here +// capitalise function takes 1 str arg +// let srting will give an error if i try to pass my string. +// remove let +// str is being put in template literal +// str[0]: 1st index of str becomes uppercase +// str.slice(1): 2nd index slice until end of str +// str = "frankocean" +// return = "Frankocean" + // 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)}`; + str = `${str[0].toUpperCase()}${str.slice(1)}`; return str; } // =============> write your explanation here +// let str = `${str[0].toUpperCase()}${str.slice(1)}`; +// I was right, error given is because of let str within the function. +// SyntaxError: Identifier 'str' has already been declared +// We cannot have two declarations of the same variable so we remove the let inside .capitalise. // =============> write your new code here +console.log(capitalise("frankocean")) From 194c793d9f418142597209b7f6aab55e50d6ed3c Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 10:32:04 +0200 Subject: [PATCH 30/41] Added original code and moved my code to end --- Sprint-3/1-key-errors/0.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/0.js b/Sprint-3/1-key-errors/0.js index 50758c19e..4b8adb940 100644 --- a/Sprint-3/1-key-errors/0.js +++ b/Sprint-3/1-key-errors/0.js @@ -13,10 +13,11 @@ // call the function capitalise with a string input // interpret the error message and figure out why an error is occurring -function capitalise(str) { - 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 // let str = `${str[0].toUpperCase()}${str.slice(1)}`; @@ -24,4 +25,8 @@ function capitalise(str) { // SyntaxError: Identifier 'str' has already been declared // We cannot have two declarations of the same variable so we remove the let inside .capitalise. // =============> write your new code here +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} console.log(capitalise("frankocean")) From ac1886b48e50ec388499488f90f8e2821ad67f30 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 10:41:06 +0200 Subject: [PATCH 31/41] Predicted, explained and fixed the code errors. --- Sprint-3/1-key-errors/1.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-key-errors/1.js b/Sprint-3/1-key-errors/1.js index f2d56151f..66901d730 100644 --- a/Sprint-3/1-key-errors/1.js +++ b/Sprint-3/1-key-errors/1.js @@ -2,19 +2,33 @@ // Why will an error occur when this program runs? // =============> write your prediction here +// decimalNumber declared inside the function, this is the value that must be an arg +// line 17 also fails because it tries to access a var that is declared within the function // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { - const decimalNumber = 0.5; - const percentage = `${decimalNumber * 100}%`; +// function convertToPercentage(decimalNumber) { +// const decimalNumber = 0.5; +// const percentage = `${decimalNumber * 100}%`; - return percentage; -} +// return percentage; +// } -console.log(decimalNumber); +// console.log(decimalNumber); // =============> write your explanation here +// Remove the local var declaration +// ReferenceError: decimalNumber is not defined | console.log(decimalNumber); +// define decimalNumber in line 17 by passing the function with decimalNumber value +// remove the definition in line 11 // 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(0.5)); From cd6e897c599d0915820dcc56e7623cef34e8a019 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 11:12:30 +0200 Subject: [PATCH 32/41] Predicted, explained and fixed code errors --- Sprint-3/1-key-errors/2.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-key-errors/2.js b/Sprint-3/1-key-errors/2.js index aad57f7cf..1e01ecb9b 100644 --- a/Sprint-3/1-key-errors/2.js +++ b/Sprint-3/1-key-errors/2.js @@ -4,17 +4,25 @@ // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here +// Error because 3 is a value, functions take parameters(like num). +// It wont work 3 is a number literal and not a name/identifier. -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 code was expecting the parameter name but found the number literal =3 +// This is why we get the syntax error. // Finally, correct the code to fix the problem // =============> write your new code here +function square(num) { + return num * num; +} - +console.log(square(3)); \ No newline at end of file From 689ea337146bde1d3f400448d840aa9007db79d7 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 11:43:50 +0200 Subject: [PATCH 33/41] Predicted, explained and fixed code errors --- Sprint-3/2-mandatory-debug/0.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/0.js b/Sprint-3/2-mandatory-debug/0.js index b27511b41..4307eeac4 100644 --- a/Sprint-3/2-mandatory-debug/0.js +++ b/Sprint-3/2-mandatory-debug/0.js @@ -1,14 +1,26 @@ // Predict and explain first... // =============> write your prediction here +// It will print 2 lines: +// (10*32=320) line 1: 320 +// line 2: The result of multiplying 10 and 32 is undefined -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 +// There are two console.log() being called. +// The one inside the funtion prints the result of the multiplication +// The one outside the function prints the desired result of the whole string but there is no return from the function so it is undefined +// The result of multiplying 10 and 32 is undefined. // Finally, correct the code to fix the problem // =============> write your new code here +function multiply(a, b) { + return a * b; +} + +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); From cf34a2616372513ae1f682b6c772bdf1183de7d5 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 11:52:23 +0200 Subject: [PATCH 34/41] Predicted, explained and fixed code errors --- Sprint-3/2-mandatory-debug/1.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/1.js b/Sprint-3/2-mandatory-debug/1.js index 37cedfbcf..cf860db05 100644 --- a/Sprint-3/2-mandatory-debug/1.js +++ b/Sprint-3/2-mandatory-debug/1.js @@ -1,13 +1,24 @@ // Predict and explain first... // =============> write your prediction here +// I dont think the code will run at all since the return is separated from the sum that should happen +// the console.log() oustide the function will say the sum is undefined. -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 sum of 10 and 32 is undefined +// I was wrong, I thought that the code would not run. +// The output says the sum is undefined because the return statement and the "a + b" are separated by ; +// To fix it, I just need to remove the ; next to return on line 7. // Finally, correct the code to fix the problem // =============> write your new code here +function sum(a, b) { + return a + b; +} + +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); \ No newline at end of file From 595728f70bc33c7a96c4787a9034c9866b69ace8 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 12:00:34 +0200 Subject: [PATCH 35/41] Predicted, explained and fixed code errors --- Sprint-3/2-mandatory-debug/2.js | 35 ++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Sprint-3/2-mandatory-debug/2.js b/Sprint-3/2-mandatory-debug/2.js index 57d3f5dc3..726549eb8 100644 --- a/Sprint-3/2-mandatory-debug/2.js +++ b/Sprint-3/2-mandatory-debug/2.js @@ -2,23 +2,44 @@ // Predict the output of the following code: // =============> Write your prediction here +// Nothing is going to run properly because the function does not have any parameters. +// I think everything will get a syntax error -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 +// 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 +// I was wrong in my prediction. Code runs. +// It says the last digit is 3 for every number which is wrong +// This is because we declared the var num = 103 globally, and it is affecting all the fucntion calls +// Because of the global declaration, every function call is going to use the global num +// This is bad because the code is now taking in diferent parameters but returning a value based on one global value. +// TO fix this we remove the global var num. +// Then we add num as a parameter in the function :getLastDigit(num) + // Finally, correct the code to fix the problem // =============> write your new code here +function getLastDigit(num) { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem From 3c8783e2e74459499b6b32957c62b34ea026897a Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 12:40:31 +0200 Subject: [PATCH 36/41] BMI calculator function --- Sprint-3/3-mandatory-implement/1-bmi.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/1-bmi.js b/Sprint-3/3-mandatory-implement/1-bmi.js index 58b1085f1..eded36a45 100644 --- a/Sprint-3/3-mandatory-implement/1-bmi.js +++ b/Sprint-3/3-mandatory-implement/1-bmi.js @@ -16,4 +16,6 @@ function calculateBMI(weight, height) { // return the BMI of someone based off their weight and height + return (weight / (height * height)).toFixed(1) } +console.log(calculateBMI(70, 1.73)) \ No newline at end of file From 0b6a121d5be8251ce2d85ae285049e94020f422b Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 12:52:29 +0200 Subject: [PATCH 37/41] Upper case and underscore conversion of strings --- Sprint-3/3-mandatory-implement/2-cases.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/3-mandatory-implement/2-cases.js b/Sprint-3/3-mandatory-implement/2-cases.js index 5b0ef77ad..943eabf25 100644 --- a/Sprint-3/3-mandatory-implement/2-cases.js +++ b/Sprint-3/3-mandatory-implement/2-cases.js @@ -14,3 +14,10 @@ // 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 UPPER_SNAKE_CASE(str) { + let snake_case = str.replaceAll(" ", "_"); + return snake_case.toUpperCase() +} + +console.log(UPPER_SNAKE_CASE("have you ever had a krispy kreme")) \ No newline at end of file From a680b434b9d58dfe334285572daafda39e43fdc1 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 13:15:41 +0200 Subject: [PATCH 38/41] Conversion function from sprint 2, to-pounds --- Sprint-3/3-mandatory-implement/3-to-pounds.js | 13 +++++++++++++ 1 file changed, 13 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..a7f3178d4 100644 --- a/Sprint-3/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-3/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,16 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs + +function toPounds(str) { + let penceStringWithoutTrailingP = str.substring(0, str.length - 1); + + let paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + let pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2); + + let pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); + + console.log(`£${pounds}.${pence}`); +} + +toPounds("5045p") \ No newline at end of file From 7277b60f9a82b715939d30fbc568f8e43e7534b4 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 13:37:50 +0200 Subject: [PATCH 39/41] Answered questions, rem calculations --- Sprint-3/4-mandatory-interpret/time-format.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sprint-3/4-mandatory-interpret/time-format.js b/Sprint-3/4-mandatory-interpret/time-format.js index c0dd9c9a5..f53bec84e 100644 --- a/Sprint-3/4-mandatory-interpret/time-format.js +++ b/Sprint-3/4-mandatory-interpret/time-format.js @@ -7,10 +7,10 @@ function pad(num) { } function formatTimeDisplay(seconds) { - const remainingSeconds = seconds % 60; - const totalMinutes = (seconds - remainingSeconds) / 60; - const remainingMinutes = totalMinutes % 60; - const totalHours = (totalMinutes - remainingMinutes) / 60; + const remainingSeconds = seconds % 60; // 1 + const totalMinutes = (seconds - remainingSeconds) / 60; // 1 + const remainingMinutes = totalMinutes % 60; // 1 + const totalHours = (totalMinutes - remainingMinutes) / 60; //0 return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } @@ -21,18 +21,18 @@ function formatTimeDisplay(seconds) { // Questions // a) When formatTimeDisplay is called how many times will pad be called? -// =============> write your answer here +// 3 times // Call formatTimeDisplay with an input of 61, now answer the following: - +console.log(formatTimeDisplay(61)) // 00:01:01 // b) What is the value assigned to num when pad is called for the first time? -// =============> write your answer here +// 0 // c) What is the return value of pad when it is called for the first time? -// =============> write your answer here +// "00" // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer -// =============> write your answer here +// 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 +// "01" From 388daadea82fa3b0465db63137f073affe59fc36 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 14:36:11 +0200 Subject: [PATCH 40/41] Added test cases, in process of fixing code --- Sprint-3/5-stretch-extend/format-time.js | 67 ++++++++++++++++++------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/Sprint-3/5-stretch-extend/format-time.js b/Sprint-3/5-stretch-extend/format-time.js index 32a32e66b..f7609b09f 100644 --- a/Sprint-3/5-stretch-extend/format-time.js +++ b/Sprint-3/5-stretch-extend/format-time.js @@ -2,24 +2,61 @@ // 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. +// original code: +// function formatAs12HourClock(time) { +// const hours = Number(time.slice(0, 2)); +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// const currentOutput = formatAs12HourClock("08:00"); +// const targetOutput = "08:00 am"; +// console.assert( +// currentOutput === targetOutput, +// `current output: ${currentOutput}, target output: ${targetOutput}` +// ); + +// const currentOutput2 = formatAs12HourClock("23:00"); +// const targetOutput2 = "11:00 pm"; +// console.assert( +// currentOutput2 === targetOutput2, +// `current output: ${currentOutput2}, target output: ${targetOutput2}` +// ); + +// my code: function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; + if (hours >= 12) { + return `${hours - 12}:${time.slice(3)} pm`; } - return `${time} am`; + return `${time}:${time.slice(3)} am`; } -const currentOutput = formatAs12HourClock("08:00"); -const targetOutput = "08:00 am"; -console.assert( - currentOutput === targetOutput, - `current output: ${currentOutput}, target output: ${targetOutput}` -); +const cases = [ + { input: "00:00", expected: "12:00 am" }, // midnight + { input: "01:00", expected: "01:00 am" }, + { input: "02:00", expected: "02:00 am" }, // your failing test + { input: "09:00", expected: "09:00 am" }, + { input: "11:59", expected: "11:59 am" }, + { input: "12:00", expected: "12:00 pm" }, // noon + { input: "12:30", expected: "12:30 pm" }, + { input: "13:00", expected: "01:00 pm" }, + { input: "23:00", expected: "11:00 pm" }, // your other test + { input: "23:59", expected: "11:59 pm" }, +]; -const currentOutput2 = formatAs12HourClock("23:00"); -const targetOutput2 = "11:00 pm"; -console.assert( - currentOutput2 === targetOutput2, - `current output: ${currentOutput2}, target output: ${targetOutput2}` -); +function runTests(cases) { + let passed = 0; + for (const { input, expected } of cases) { + const actual = formatAs12HourClock(input); + const ok = actual === expected; + if (ok) passed++; + console.log( + `${ok ? "PASS" : "FAIL"} input: ${input} expected: ${expected} actual: ${actual}` + ); + } + console.log(`\n${passed}/${cases.length} passed`); +} +runTests(cases); \ No newline at end of file From 47508e8cb3ceda7061b506abc2b5a5cfbabfe1b5 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Wed, 23 Sep 2026 15:05:26 +0200 Subject: [PATCH 41/41] Reset Sprint-2 to match main --- Sprint-2/1-key-exercises/1-count.js | 2 -- Sprint-2/1-key-exercises/2-initials.js | 8 +------- Sprint-2/1-key-exercises/3-paths.js | 9 ++------- Sprint-2/1-key-exercises/4-random.js | 8 -------- Sprint-2/2-mandatory-errors/0.js | 6 ++---- Sprint-2/2-mandatory-errors/1.js | 3 +-- Sprint-2/2-mandatory-errors/2.js | 4 +--- Sprint-2/2-mandatory-errors/3.js | 4 +--- Sprint-2/2-mandatory-errors/4.js | 5 ++--- .../3-mandatory-interpret/1-percentage-change.js | 9 ++------- Sprint-2/3-mandatory-interpret/2-time-format.js | 9 --------- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 7 ------- Sprint-2/4-stretch-explore/chrome.md | 16 ---------------- Sprint-2/4-stretch-explore/objects.md | 14 -------------- 14 files changed, 12 insertions(+), 92 deletions(-) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 6cadfef2b..117bcb2b6 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -4,5 +4,3 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing - -// count is being increased each time the code runs by +1. = is basically just reassigning the value each time. diff --git a/Sprint-2/1-key-exercises/2-initials.js b/Sprint-2/1-key-exercises/2-initials.js index 45eef73ed..964c9563c 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,12 +5,6 @@ const lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -const firstChar = firstName.charAt(0); -const secondChar = middleName.charAt(0); -const thirdChar = lastName.charAt(0); - - -const initials = `${firstChar}${secondChar}${thirdChar}`; -console.log(initials) +const initials = ``; // https://www.google.com/search?q=get+first+character+of+string+mdn diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 236293c94..ab90ebb28 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -17,12 +17,7 @@ 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); -const ext = filePath.slice(filePath.lastIndexOf("."), filePath.length); - -console.log(dir) -console.log(ext) +const dir = ; +const ext = ; // https://www.google.com/search?q=slice+mdn \ No newline at end of file diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 76182687f..292f83aab 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -7,11 +7,3 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // 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 - -// Math.floor() - rounds down to nearest integer -// Math.random() - gives a random number -// (max - min + 1) - 100 -// simple bodmas bro - -// math.random = 2 -// num = 201 \ No newline at end of file diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index a76715850..cf6c5039f 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,4 +1,2 @@ -// 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? - -// Comment out lines with "//" \ 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? \ No newline at end of file diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index e03657d95..7a43cbea7 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,5 +1,4 @@ // trying to create an age variable and then reassign the value by 1 -let age = 33; +const age = 33; age = age + 1; -// changed const to let \ No newline at end of file diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index 7f3af0111..e09b89831 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,7 +1,5 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? -const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); - -// You must first assign the var before u try to print it \ No newline at end of file +const cityOfBirth = "Bolton"; diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index 8173975fa..ec101884d 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,4 +1,4 @@ -const cardNumber = "4533787178994213"; +const cardNumber = 4533787178994213; const last4Digits = cardNumber.slice(-4); // The last4Digits variable should store the last 4 digits of cardNumber @@ -7,5 +7,3 @@ const last4Digits = cardNumber.slice(-4); // Then run the code and see what error it gives. // Consider: Why does it give this error? Is this what I predicted? If not, what's different? // Then try updating the expression last4Digits is assigned to, in order to get the correct value -console.log(last4Digits) -// cardNumber was stored as a number, which does not work with .splice(). \ No newline at end of file diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 0d4f38e63..5f86c730b 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,3 +1,2 @@ -const twelveHourClockTime = "8:53pm"; -const miliataryhourClockTime = "20:53"; -// variables cannot start with a number. \ No newline at end of file +const 12HourClockTime = "8:53pm"; +const 24hourClockTime = "20:53"; diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index a1b00f2ea..e24ecb8e1 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -1,8 +1,8 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; -carPrice = Number(carPrice.replaceAll(",","")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",","")); +carPrice = Number(carPrice.replaceAll(",", "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; @@ -12,16 +12,11 @@ console.log(`The percentage change is ${percentageChange}`); // Read the code and then answer the questions below // a) How many function calls are there in this file? Write down all the lines where a function call is made -// Number() line 4,5. .replaceAll() line 4,5. console.log() line 10. // 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? -// line 5: put a comma between the find and replace // c) Identify all the lines that are variable reassignment statements -// line 4, 5. // d) Identify all the lines that are variable declarations -// line 1,2,7,8. // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? -// convert str to number type and find and replace commas with nothing so that the number is read correctly. \ No newline at end of file diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index b4c7035c9..47d239558 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -12,23 +12,14 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? -// 6 // b) How many function calls are there? -// 1 // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators -// its a rem calculation, basically taking how many groups of 60 are in the movie, and giving back the remainder. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? -// (movieLength - remainingSeconds): gives us a value that's an exact multiple of 60, so it divides evenly. -// / 60: takes the whole number and converts it to minutes // e) What do you think the variable result represents? Can you think of a better name for this variable? -// the movie length in hours, minutes and seconds. formattedDuration // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer -// edge cases: negative movie length. For negative movie lengths it should print an error saying that movielength cannot be less than 0. -// : decimal numbers -// : should tell user that the unit is seconds diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index 0435be1ff..60c9ace69 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,10 +25,3 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" -// 2. const penceStringWithoutTrailingP: from index 0, to length of string - 1 (4-1=3). (0,3) we get the string from index 0 to index 2 which removes the p at the end. -// 3. const paddedPenceNumberString: if length < 3, pad start of string with "0". since it is we just get 399. -// 4. const pounds: take string from index 0 to length of string - 2 (3-2=1). (0,1) we get the 1st index "3". -// 5. .substring(): length = 3. (3-2=1). (1,end of string). this gives us 99 -// 6. .padEnd(): if previous length of string < 2: pad end with "0" -// 7. console.log() basically just prints pounds and pence as the proper format (£"pound"."pence") using string literals -// NB: padding is for a safety measure if the inputs were shorter. \ No newline at end of file diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 403640cd5..962580b82 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -9,23 +9,7 @@ In the Chrome console, invoke the function `alert` with one argument, the string What effect does calling the `alert` function have? -// Alert brings a pop up window out and says "Hello world" from the page. It also has a button called "OK" - Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? What is the return value of `prompt`? - -// Opens a popup box with a text input. The value inside the () is what would display above the input. -// The return value is myname? - -This is the code I did. -alert("Hello world") -undefined -prompt("What is your name") -'Tylerluvslasagne' -let myname = prompt("what is yur name") -undefined -console.log(myname) -VM319:1 I LOVE MY EX -undefined \ No newline at end of file diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index be8a79745..0216dee56 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -13,18 +13,4 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? -// Console is an object that stores properties as fucntions. (Think of import = math, math.sqrt(9)) - What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? -// It means that you are calling on console to run this particular function in your javascript code. -// console.log: access property(log) inside object(console). -// The . is the property access operator. -// The () contain an argument(s) which run the code. - -My code: -console.log - ƒ log() { [native code] } -console - console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} -typeof console - 'object' \ No newline at end of file