From 4ad25d3ec3cb218b2efd5064657a5ffcc77ce3ff Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:19:50 +0100 Subject: [PATCH 01/18] Restore prep work for Sprint 2 --- prep/facts.js | 1 + prep/greeting.js | 1 + prep/hello_world.js | 1 + prep/user interface.md | 8 ++++++++ 4 files changed, 11 insertions(+) create mode 100644 prep/facts.js create mode 100644 prep/greeting.js create mode 100644 prep/hello_world.js create mode 100644 prep/user interface.md diff --git a/prep/facts.js b/prep/facts.js new file mode 100644 index 000000000..06734df4e --- /dev/null +++ b/prep/facts.js @@ -0,0 +1 @@ +console.log("I live in Sheffield.") diff --git a/prep/greeting.js b/prep/greeting.js new file mode 100644 index 000000000..b36b78b87 --- /dev/null +++ b/prep/greeting.js @@ -0,0 +1 @@ +const greeting = "Hello there"; diff --git a/prep/hello_world.js b/prep/hello_world.js new file mode 100644 index 000000000..422c89ef9 --- /dev/null +++ b/prep/hello_world.js @@ -0,0 +1 @@ +console.log("Hello, World!") diff --git a/prep/user interface.md b/prep/user interface.md new file mode 100644 index 000000000..b20168aa6 --- /dev/null +++ b/prep/user interface.md @@ -0,0 +1,8 @@ +| Device | User interface | +| ------------- | ------------------------------------- | +| 🧮 Calculator | Buttons and display | +| 📱 Microwave | Buttons, display and sounds | +| 💡 Lamp | Switch or button | +| 👍 Facebook | Screen, buttons, menus and text boxes | +| 🗣️ Alexa | Mainly your voice, plus buttons/app | +| 💬 ChatGPT | Chat box, buttons, menus and screen | From cbfb18131f299811b5ec71c474591c5d05820aac Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:29:47 +0100 Subject: [PATCH 02/18] Complete count exercise --- 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 117bcb2b6..32e8be782 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -1,6 +1,7 @@ let count = 0; count = count + 1; +console.log(count); // 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 From 40cbf97525ed43d83e7b23013f103566b45d929d Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:29:55 +0100 Subject: [PATCH 03/18] Complete initials exercise --- Sprint-2/1-key-exercises/2-initials.js | 3 ++- 1 file changed, 2 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..804978abd 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,6 +5,7 @@ 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 initials = `${firstName[0]}${middleName[0]}${lastName[0]}`; +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From 52f345105bcfcce10050cb695c0fba36fc781bdd Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:02 +0100 Subject: [PATCH 04/18] Complete paths exercise --- 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 ab90ebb28..43eddfd46 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -17,7 +17,8 @@ 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(0, lastSlashIndex); +const ext = filePath.slice(filePath.lastIndexOf(".") + 1); +console.log({ dir, ext }); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From c05aa8569d3e41c2a01b8ce71ee95a403917e6f6 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:10 +0100 Subject: [PATCH 05/18] Complete random number exercise --- Sprint-2/1-key-exercises/4-random.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..644752d31 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -2,6 +2,7 @@ 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 From 05cb7b5b180788c570d90f7a32bfde96107f41ae Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:19 +0100 Subject: [PATCH 06/18] Document error explanation example --- Sprint-2/2-mandatory-errors/0.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..214eb7cc7 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,2 +1,7 @@ -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 only for human consumption. +// We don't want the computer to run these 2 lines - how can we solve this problem? +// +// To stop JavaScript from running them, turn them into comments: +// +// const age = 33; +// age = age + 1; From 2edba649fe35b9e76b5a1fc70e6f5ae8f47a938e Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:31 +0100 Subject: [PATCH 07/18] Fix reassignment error --- Sprint-2/2-mandatory-errors/1.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..4a89a12a3 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,4 +1,6 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; +// Use let instead of const so the value can be reassigned. age = age + 1; +console.log(age); From 0fc07717e6272f70eb6dca9eb0d5a95539af9bfe Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:40 +0100 Subject: [PATCH 08/18] Fix city declaration error --- Sprint-2/2-mandatory-errors/2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..cf934c587 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,5 +1,6 @@ // 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"; +// Declare the variable before using it in the template literal. +console.log(`I was born in ${cityOfBirth}`); From 80bc588ff507fc57feeb464abbfc1b7679b5d69f Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:48 +0100 Subject: [PATCH 09/18] Fix card number slicing error --- 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..08d02e30f 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -1,5 +1,7 @@ const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +// Convert the number to a string before slicing to get the last four digits. +const last4Digits = String(cardNumber).slice(-4); +console.log(last4Digits); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working From f34c0daaa12a521d766610debd9d13a9c2b98040 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:30:55 +0100 Subject: [PATCH 10/18] Fix invalid variable names --- Sprint-2/2-mandatory-errors/4.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..b0ea867af 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,5 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +// Variable names cannot begin with a number, so use descriptive names instead. +const twelveHourClockTime = "8:53pm"; +const twentyFourHourClockTime = "20:53"; +console.log(twelveHourClockTime); +console.log(twentyFourHourClockTime); From 6a1011277cec34bc288a194508cdd6337010b392 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:42:06 +0100 Subject: [PATCH 11/18] Complete percentage change interpretation --- .../1-percentage-change.js | 18 +++++++++++++++++- 1 file changed, 17 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..4dac49ada 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; @@ -12,11 +12,27 @@ console.log(`The percentage change is ${percentageChange}`); // Read the code and then answer the questions below // a) How many function calls are there in this file? Write down all the lines where a function call is made +// There are 5 function calls: +// - line 4: carPrice.replaceAll(",", "") +// - line 5: priceAfterOneYear.replaceAll(",", "") +// - line 4: Number(...) +// - line 5: Number(...) +// - line 9: console.log(...) // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? +// The error occurs at line 5 because the syntax is invalid: replaceAll("," "") is missing a comma between the arguments. +// Fix it by writing replaceAll(",", ""). // c) Identify all the lines that are variable reassignment statements +// - line 4: carPrice = Number(...) +// - line 5: priceAfterOneYear = Number(...) // d) Identify all the lines that are variable declarations +// - line 1: let carPrice = "10,000"; +// - line 2: let priceAfterOneYear = "8,543"; +// - line 7: const priceDifference = carPrice - priceAfterOneYear; +// - line 8: const percentageChange = (priceDifference / carPrice) * 100; // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// It removes the commas from the string, then converts the cleaned string into a number. +// This is necessary because the prices are stored as strings like "10,000" and "8,543", and we need to perform arithmetic on them. From 28d1d370ec106a1ce4b02bf959f0615f71a1ea4b Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:42:07 +0100 Subject: [PATCH 12/18] Complete time format interpretation --- Sprint-2/3-mandatory-interpret/2-time-format.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index 47d239558..c3238c516 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,26 @@ 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? +// There are 7 variable declarations: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result, and maybe the console.log has none. +// (If counting only const declarations, there are 6: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result.) // b) How many function calls are there? +// There is 1 function call: console.log(result) // c) Using documentation, explain what the expression movieLength % 60 represents +// % is the remainder operator. It gives the remainder when movieLength is divided by 60. +// For 8784 seconds, 8784 % 60 = 24, so there are 24 seconds remaining after full minutes are counted. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// totalMinutes = (movieLength - remainingSeconds) / 60 +// This removes the extra seconds left over after full minutes are taken out, then divides by 60 to convert the remaining whole seconds into total minutes. +// For 8784 seconds, this gives 146 minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? +// result represents the time formatted as hours:minutes:seconds. +// A better name could be timeString or formattedTime. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// It works for any non-negative number of seconds, because it calculates hours, minutes, and seconds using division and remainders. +// It will not format correctly for negative values, and it assumes the value is in seconds rather than another unit. From dbf28af09fb8d70a303666fb9cfb1008be0e91ec Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:42:08 +0100 Subject: [PATCH 13/18] Complete pounds conversion interpretation --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 8 ++++++++ 1 file changed, 8 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..66333adac 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,11 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" +// 2. penceString.substring(0, penceString.length - 1): removes the final "p" character so only the digits remain +// 3. padStart(3, "0"): ensures the value has at least 3 characters by adding leading zeros if needed +// 4. pounds = the first part of the padded string, excluding the last two digits, so the whole pounds part is preserved +// 5. pence = the final two digits, padded to 2 characters, to keep a valid pence value +// 6. console.log(`£${pounds}.${pence}`): prints the formatted result as a pounds and pence string + +// For "399p", the steps work like this: +// "399p" -> "399" -> "399" -> pounds = "3" and pence = "99" -> output "£3.99" From 4b2b429684645720d2a2b8e04ea23dc682d5ecf9 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:42:08 +0100 Subject: [PATCH 14/18] Complete objects stretch task --- Sprint-2/4-stretch-explore/objects.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index 0216dee56..78a51d8c9 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -13,4 +13,11 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? +`console` stores the browser's debugging object. It contains methods such as `log`, `error`, `warn`, and `assert` that let us print values and inspect program state. + What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +The `.` is the property access operator. It means "look inside the `console` object and use the `log` or `assert` method stored there". +So `console.log(...)` means “call the `log` method on the `console` object”. + +Try also entering `typeof console`. +This returns `"object"`, because `console` is an object containing methods. From 0e5b329d73dbd12772b99fed51cc23302f1674c4 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 14:42:09 +0100 Subject: [PATCH 15/18] Complete Chrome console stretch task --- Sprint-2/4-stretch-explore/chrome.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 962580b82..ec410d2f4 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -8,8 +8,12 @@ Let's try an example. In the Chrome console, invoke the function `alert` with one argument, the string `"Hello world!"`; What effect does calling the `alert` function have? +It shows a pop-up dialog box with the message "Hello world!" and pauses the browser until the user closes it. 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? +It displays a dialog box asking the user for input. + What is the return value of `prompt`? +The return value is the text entered by the user as a string. If the user cancels the prompt, it returns `null`. From 820cbc8514d7c2674dd649425d56d06acf5bfb41 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 15:24:14 +0100 Subject: [PATCH 16/18] Add count exercise explanation --- Sprint-2/1-key-exercises/1-count.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 32e8be782..aef978c77 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -4,4 +4,6 @@ count = count + 1; console.log(count); // 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 is using the assignment operator (=) to update the value of count. +// It reads the current value of count, adds 1 to it, and then stores the result back into count. +// So the value changes from 0 to 1. From b93c32ab59725eaa0c976fe64ef11cd34ebf891b Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 15:33:56 +0100 Subject: [PATCH 17/18] Correct time format interpretation count --- Sprint-2/3-mandatory-interpret/2-time-format.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/2-time-format.js b/Sprint-2/3-mandatory-interpret/2-time-format.js index c3238c516..45134753d 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -12,8 +12,7 @@ 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? -// There are 7 variable declarations: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result, and maybe the console.log has none. -// (If counting only const declarations, there are 6: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result.) +// There are 6 variable declarations: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, and result. // b) How many function calls are there? // There is 1 function call: console.log(result) From 440a54b20b48fe39f2a5572116e2459acf0763c3 Mon Sep 17 00:00:00 2001 From: BrianY315 Date: Mon, 21 Sep 2026 16:12:39 +0100 Subject: [PATCH 18/18] Remove stray prep files from Sprint 2 branch --- prep/facts.js | 1 - prep/greeting.js | 1 - prep/hello_world.js | 1 - prep/user interface.md | 8 -------- 4 files changed, 11 deletions(-) delete mode 100644 prep/facts.js delete mode 100644 prep/greeting.js delete mode 100644 prep/hello_world.js delete mode 100644 prep/user interface.md diff --git a/prep/facts.js b/prep/facts.js deleted file mode 100644 index 06734df4e..000000000 --- a/prep/facts.js +++ /dev/null @@ -1 +0,0 @@ -console.log("I live in Sheffield.") diff --git a/prep/greeting.js b/prep/greeting.js deleted file mode 100644 index b36b78b87..000000000 --- a/prep/greeting.js +++ /dev/null @@ -1 +0,0 @@ -const greeting = "Hello there"; diff --git a/prep/hello_world.js b/prep/hello_world.js deleted file mode 100644 index 422c89ef9..000000000 --- a/prep/hello_world.js +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello, World!") diff --git a/prep/user interface.md b/prep/user interface.md deleted file mode 100644 index b20168aa6..000000000 --- a/prep/user interface.md +++ /dev/null @@ -1,8 +0,0 @@ -| Device | User interface | -| ------------- | ------------------------------------- | -| 🧮 Calculator | Buttons and display | -| 📱 Microwave | Buttons, display and sounds | -| 💡 Lamp | Switch or button | -| 👍 Facebook | Screen, buttons, menus and text boxes | -| 🗣️ Alexa | Mainly your voice, plus buttons/app | -| 💬 ChatGPT | Chat box, buttons, menus and screen |