From f428d25dca8abea105e0f853bfac43573f88d815 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 15:44:33 +0000 Subject: [PATCH 01/17] answer for count.js in comments --- Sprint-1/1-key-exercises/1-count.js | 3 +++ Sprint-1/1-key-exercises/2-initials.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..ddc6cf1dc 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,6 @@ count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing + +//Answer: +//Line 3 re-assigns the value of count and declares a new value increasing count by 1 \ No newline at end of file diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..007cd2911 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,7 @@ let lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -let initials = ``; +let initials =`${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`; // https://www.google.com/search?q=get+first+character+of+string+mdn From db7592c5ad721675f0dae9359e2873e8e7a3cf10 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 16:18:19 +0000 Subject: [PATCH 02/17] answer for initials.js with comments --- Sprint-1/1-key-exercises/2-initials.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 007cd2911..401ddf4fe 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,14 @@ let lastName = "Johnson"; // Declare a variable called initials that stores the first character of each string. // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. -let initials =`${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`; +//Answer: +//Solution using charAt() a Javascript string method that returns a character's position, using template literal +// and toUpperCase to ensure it is capitalized. +let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`.toUpperCase(); + + +//alternative solution using string indexing, template literal and toUppercase(to make sure it is capitalized) +//let initials - `${firstName[0]}${middleName[0]}${lastName[0]}`.toUpperCase()); // https://www.google.com/search?q=get+first+character+of+string+mdn From a66e3fe8ece232d037b3acd548e87f6bb8344424 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 18:19:25 +0000 Subject: [PATCH 03/17] completed paths.js with added comments --- Sprint-1/1-key-exercises/3-paths.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..60a3b1fa6 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,19 @@ 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 = ; +//Answer: +//**where the file lives^^ +// It gives me everything from Index 0 to +// the last slash just before the filename. +const dir = filePath.slice(0, lastSlashIndex); +console.log(dir); + +//Answer: +//**what type of file** +//Uses the the lastIndexOf method to look for the dot. +//the dot is now index 0 so we start from index 1 onwards +// to get the file type. +const ext = filePath.slice(filePath.lastIndexOf(".") + 1); +console.log(ext); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From ed76a69b8c600020c5844b182d3428441755f34b Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 18:23:30 +0000 Subject: [PATCH 04/17] added console.log to initials.js --- Sprint-1/1-key-exercises/2-initials.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 401ddf4fe..a17b870bc 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -9,7 +9,7 @@ let lastName = "Johnson"; //Solution using charAt() a Javascript string method that returns a character's position, using template literal // and toUpperCase to ensure it is capitalized. let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`.toUpperCase(); - +console.log(initials); //alternative solution using string indexing, template literal and toUppercase(to make sure it is capitalized) //let initials - `${firstName[0]}${middleName[0]}${lastName[0]}`.toUpperCase()); From 2309db322b58d9329357bc7ee6ccfe2cb0fd4623 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 19:16:35 +0000 Subject: [PATCH 05/17] completed random.js with comments --- Sprint-1/1-key-exercises/3-paths.js | 2 +- Sprint-1/1-key-exercises/4-random.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index 60a3b1fa6..82cdfd0e1 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -18,7 +18,7 @@ console.log(`The base part of ${filePath} is ${base}`); // Create a variable to store the ext part of the variable //Answer: -//**where the file lives^^ +//**where the file lives** // It gives me everything from Index 0 to // the last slash just before the filename. const dir = filePath.slice(0, lastSlashIndex); diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..faffcc881 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -4,6 +4,23 @@ const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // In this exercise, you will need to work out what num represents? +//*Answer: +//Number returns a random whole number between 1 and 100. + // Try breaking down the expression and using documentation to explain what it means +/*Answer: +It uses 2 methods to achieve this +Math.random generate a random number between 0 and 1 eg. 0.343, 0.5. 0.67 +Math.floor rounds the number to a whole number. +In this declaration: +Math.random will return a random decimal number and multiplies it by the sum of +((maximum-minimum)+1). eg 0.343_*((100-1)+1) = 34.3. +Math.floor will take the total 34.3 and round it to a whole number 34*/ + // It will help to think about the order in which expressions are evaluated +//*Answer: +//it first works out the random decimal number calculates the other values then evaluates to sum to a whole number. + // Try logging the value of num and running the program several times to build an idea of what the program is doing +//*Answer: +//28, 64, 52, 86 From b7acb737dc22fff5413973a240af20ce0bc4dd1e Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 19:33:44 +0000 Subject: [PATCH 06/17] completed 0.js with comments --- Sprint-1/2-mandatory-errors/0.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..b05d58db9 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,8 @@ -This is just an instruction for the first activity - but it is just for human consumption -We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file +/*This is just an instruction for the first activity - but it is just for human consumption +We don't want the computer to run these 2 lines - how can we solve this problem?*/ + +//*Answer +// We comment it out, +// We can do this by using a two forward slashes ("//")if it is on one line +//or we use one forward slash with an asterisk at the start("/*") and an asterisk +// and a forward slash at the end ("*/") for block commenting \ No newline at end of file From 8af030affb262156ceb7ce4cf56b922ef0190fb6 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 19:41:30 +0000 Subject: [PATCH 07/17] completed 1.js with comments --- Sprint-1/2-mandatory-errors/0.js | 2 +- Sprint-1/2-mandatory-errors/1.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index b05d58db9..779581a32 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -5,4 +5,4 @@ We don't want the computer to run these 2 lines - how can we solve this problem? // We comment it out, // We can do this by using a two forward slashes ("//")if it is on one line //or we use one forward slash with an asterisk at the start("/*") and an asterisk -// and a forward slash at the end ("*/") for block commenting \ No newline at end of file +// and a forward slash at the end ("*/") for block commenting diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..7e5003a0f 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,3 +2,10 @@ const age = 33; age = age + 1; + +//Answer: +//we cannot re-assign variables with "const". +// We have use "let". let allows the variable to be re-assigned. + +let age = 33; +age = 33 + 1; \ No newline at end of file From 001babadbf80f6cbc48b3fa26b6a39226edaea50 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 19:43:13 +0000 Subject: [PATCH 08/17] completed 1.js made correction change number to age --- Sprint-1/2-mandatory-errors/1.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7e5003a0f..2496ad381 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -6,6 +6,5 @@ age = age + 1; //Answer: //we cannot re-assign variables with "const". // We have use "let". let allows the variable to be re-assigned. - let age = 33; -age = 33 + 1; \ No newline at end of file +age = age + 1; From 8348eb6669813237948a62842973fbe6b19d02c2 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 19:50:32 +0000 Subject: [PATCH 09/17] completed 2.js with comments --- Sprint-1/2-mandatory-errors/2.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..794de4671 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,10 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +//*Answer +// The console.log is before the variable and it cannot see it. +// The console log needs to be blow the variable to compute the data. + +const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); From 818acf94431bd73332878b8d6d9f5d477c92b8ac Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 20:20:37 +0000 Subject: [PATCH 10/17] completed 3.js with comments also commented out question in 1.js and 2.js --- Sprint-1/2-mandatory-errors/1.js | 5 +++-- Sprint-1/2-mandatory-errors/2.js | 6 +++--- Sprint-1/2-mandatory-errors/3.js | 19 +++++++++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 2496ad381..1ddae46c7 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,10 +1,11 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; -age = age + 1; +//const age = 33; +//age = age + 1; //Answer: //we cannot re-assign variables with "const". // We have use "let". let allows the variable to be re-assigned. let age = 33; age = age + 1; +console.log(age); diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index 794de4671..15c9eba46 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,12 +1,12 @@ // 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}`); +//const cityOfBirth = "Bolton"; //*Answer // The console.log is before the variable and it cannot see it. -// The console log needs to be blow the variable to compute the data. +// The console log needs to be below the variable to compute the data. const cityOfBirth = "Bolton"; console.log(`I was born in ${cityOfBirth}`); diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..b91ca2455 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,9 +1,24 @@ -const cardNumber = 4533787178994213; -const last4Digits = cardNumber.slice(-4); +//const cardNumber = 4533787178994213; +//const last4Digits = cardNumber.slice(-4); // 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 +//*Answer +//It won't work because cardNumber is not a string and .slice() only works with strings. It will throw an error. + // Then run the code and see what error it gives. +//*Answer +//Uncaught TypeError: cardNumber.slice is not a function + // Consider: Why does it give this error? Is this what I predicted? If not, what's different? +//*Answer +//I was right. cardNumber is a number not a string and .slice() only works with strings +// so it needs to be converted to a string to work using .toString() + // Then try updating the expression last4Digits is assigned to, in order to get the correct value +//*Answer +const cardNumber = 4533787178994213; +const last4Digits = cardNumber.toString().slice(-4); +console.log(last4Digits); \ No newline at end of file From e05bbcecc4336f6516d26de23e4831fc888385da Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 20:59:19 +0000 Subject: [PATCH 11/17] completed 4.js with comments --- Sprint-1/2-mandatory-errors/3.js | 2 +- Sprint-1/2-mandatory-errors/4.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index b91ca2455..d880a5c70 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -21,4 +21,4 @@ //*Answer const cardNumber = 4533787178994213; const last4Digits = cardNumber.toString().slice(-4); -console.log(last4Digits); \ No newline at end of file +console.log(last4Digits); diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..8b2a65708 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,11 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +//const 12HourClockTime = "20:53"; +//const 24hourClockTime = "08:53"; + +//What's wrong with this code? +//*Answer +//The variable is not named in line with the Javascript naming convention. +// When declaring a variable it must not start with a number, space or reserved word. +// to fix this, we can rename them correctly. + +const twelve_HourClockTime = "20:53"; +const twentyFour_HourClockTime = "08:53"; From de2a36df10d3f3155f0389cd814e9d9b31f764e6 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 21:48:22 +0000 Subject: [PATCH 12/17] completed 1-percentage-change.js with comments --- .../1-percentage-change.js | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..8bce84a53 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -1,22 +1,47 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +carPrice = Number(carPrice.replaceAll(",", "")); // returns 10000 +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",",""));//returns 8543 +//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +// incorrect code missing syntax ie a comma const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; -console.log(`The percentage change is ${percentageChange}`); +console.log(`The percentage change is ${percentageChange}`); //returns The percentage change is 14.57 // 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 +// a) How many function calls are there in this file? +// Write down all the lines where a function call is made +//*Answer +//There are 5 function calls: 2* Number(), 2*.replaceAll() and 1* console.log(). +//carPrice = Number(carPrice.replaceAll(",", "")); +//priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",","")); +//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? +// 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 it is missing a comma on line 5. +// Add the comma to fix it: ...replaceAll(",","")); // c) Identify all the lines that are variable reassignment statements +//*Answer +//carPrice = Number(carPrice.replaceAll(",", "")); +//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); + // d) Identify all the lines that are variable declarations +//let carPrice = "10,000"; +//let priceAfterOneYear = "8,543"; +//const priceDifference = carPrice - priceAfterOneYear; +//const percentageChange = (priceDifference / carPrice) * 100; + + +// e) Describe what the expression +// Number(carPrice.replaceAll(",","")) is doing - +// what is the purpose of this expression? +//It converts the carPrice into a number and removes the spaces and commas. + -// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? From 3b4e99094afa4a4a5ce1912544094fdc30e0bb92 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 23:05:03 +0000 Subject: [PATCH 13/17] completed 2-time-format.js with comments --- .../3-mandatory-interpret/2-time-format.js | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..6d4d1a186 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,37 @@ 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? +// *Answer +// There are 6. // b) How many function calls are there? +// *Answer +// There is 1; console.log() // c) Using documentation, explain what the expression movieLength % 60 represents +//*Answer +// This expression returns the remainder of seconds, after dividing the movieLength by 60, +// using the modulus operator it returns 24 seconds // 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? - -// e) What do you think the variable result represents? Can you think of a better name for this variable? -// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// *Answer +// It is converting the seconds to minutes and rounding it to the last whole minute. + +// e) What do you think the variable result represents? +//*Answer +// The result is the duration of the film in hours, minutes and seconds - 2:26:24. + +// Can you think of a better name for this variable? +// *Answer +// movieDuration + +// f) Try experimenting with different values of movieLength. +// Will this code work for all values of movieLength? Explain your answer, +// *Answer +// I changed the value to; +// 1200 returned 0:20:00 +// 92383.7 returned 25:39:43.69999999999709 +// -8784 returned -2:-26:-24 +// it worked with all numbers including decimals and negative numbers. From dc051003b1a19aceb535ac09a64d865359a870c6 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Sun, 15 Feb 2026 23:55:55 +0000 Subject: [PATCH 14/17] completed 3-to-pounds.js with comments explanation 2 --- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 6d4d1a186..ed32ba369 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -31,7 +31,7 @@ console.log(result); // It is converting the seconds to minutes and rounding it to the last whole minute. // e) What do you think the variable result represents? -//*Answer +// *Answer // The result is the duration of the film in hours, minutes and seconds - 2:26:24. // Can you think of a better name for this variable? diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..04fd62b91 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -25,3 +25,9 @@ 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 = penceString.substring(0, penceString.length - 1); +// This takes the variable penceString from the start of the string index(0) to 1 before the end +// and stops ie index (-1). and drops the last indexed character "p". + +// 3. From 7d7305a55e66f75151969a029663ed8bae3873c3 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Tue, 17 Feb 2026 20:20:05 +0000 Subject: [PATCH 15/17] completed 3-to-pounds.js with comments explanation all 1-6 --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 04fd62b91..9a133d8d3 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -24,10 +24,34 @@ console.log(`£${pounds}.${pence}`); // Try and describe the purpose / rationale behind each step // To begin, we can start with -// 1. const penceString = "399p": initialises a string variable with the value "399p" +// 1. const penceString = "399p": initialises a string variable with the value "399p" // 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1); -// This takes the variable penceString from the start of the string index(0) to 1 before the end -// and stops ie index (-1). and drops the last indexed character "p". - -// 3. +// This takes the variable penceString and uses the .substring() method to extract part of the string. +// It starts at index 0 and ends at penceString.length - 1, which removes the last character and +// outputs all characters except the trailing "p". +// This returns "399". + +// 3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); +// This takes the value of the penceStringWithoutTrailingP and uses .padStart() method to always return a minimum +// length of 3 characters. if the value computed is not a least 3 characters, it outputs leading 0's to make +// to make the string to 3 characters. If the string is 4 or more characters it just outputs the value without the leading 0's. +// This returns "399". (examples: 45 returns 045, 1295 returns 1295) + +// 4.const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2); +// This takes the value of paddedPenceNumberString and uses the .substring() method to extract the first art of the string. +// It starts at index 0 and ends at paddedPenceNumberString.length - 2, which removes the last two characters. +// This leaves the pounds portion of the value. +// This returns "3". (examples: 45 returns 0, 1295 returns 12) + +// 5.const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0"); +// This takes the variable paddedPenceNumberString and extracts the last two characters using .substring(), +// which represent the pence. If the string is shorter than 2 characters, .padEnd(2, "0") adds trailing zeros +// to ensure the pence portion is always 2 digits. +// This returns "99". (examples: 45 returns 45, 1295 returns 95) + +// 6. console.log(`£${pounds}.${pence}`); +// console.log() outputs the formatted money value to the console. It uses a template literal (backticks) +// to embed the variables `pounds` and `pence` directly inside the string using ${} syntax. +// The £ symbol is included at the start, and the dot separates pounds and pence. +// This returns "£3.99" (examples: 45 returns £0.45, 1295 returns £12.95) From a1c659f055ac4ce41200fedbb2f78977e9664232 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Tue, 17 Feb 2026 21:18:03 +0000 Subject: [PATCH 16/17] completed stretch chrome.md and objects.md with comments --- Sprint-1/4-stretch-explore/chrome.md | 8 ++++++++ Sprint-1/4-stretch-explore/objects.md | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..bceae3885 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -9,10 +9,18 @@ Let's try an example. In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; +alert('Hello World!'); What effect does calling the `alert` function have? +A pop up modal box appears with "Hello World!" 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`. +let myName = prompt("What is your name?"); What effect does calling the `prompt` function have? +It displays a modal dialog box with a text input field which can be completed. + What is the return value of `prompt`? +It is hidden, it does not display anything. The box closes. +When I do a console.log(myName); it returns Angela. + diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56..e2fc8a849 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -5,12 +5,21 @@ In this activity, we'll explore some additional concepts that you'll encounter i Open the Chrome devtools Console, type in `console.log` and then hit enter What output do you get? +ƒ log() { [native code] } Now enter just `console` in the Console, what output do you get back? +console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …} Try also entering `typeof console` +'object' Answer the following questions: What does `console` store? -What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? +It does not store anything. Its purpose is to hold a collection of methods (functions) that help you debug, log, or inspect your code. + +What does the syntax `console.log` or `console.assert` mean?, +They print outputs.It provides methods for debugging, logging, and inspecting code. + +In particular, what does the `.` mean? +The dot is a member access operator that connects the object to its property or method. From a1992d355cc0ab80815efac7ea0c2e444e96acc6 Mon Sep 17 00:00:00 2001 From: AngelaMcLeary Date: Tue, 17 Feb 2026 23:39:42 +0000 Subject: [PATCH 17/17] fixed a typo in objects.md --- Sprint-1/4-stretch-explore/objects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index e2fc8a849..6da4b7fcc 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -16,7 +16,7 @@ Try also entering `typeof console` Answer the following questions: What does `console` store? -It does not store anything. Its purpose is to hold a collection of methods (functions) that help you debug, log, or inspect your code. +It does not store anything. It's purpose is to hold a collection of methods (functions) that help you debug, log, or inspect your code. What does the syntax `console.log` or `console.assert` mean?, They print outputs.It provides methods for debugging, logging, and inspecting code.