From 401df8cbba0ca0d4b938531fabca082d4af16ed6 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Sat, 19 Sep 2026 14:06:46 +0100 Subject: [PATCH 01/17] Described what line 3 is doing & = --- Sprint-2/1-key-exercises/1-count.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 117bcb2b6..3efd03370 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -3,4 +3,10 @@ let count = 0; count = count + 1; // Line 1 is a variable declaration, creating the count variable with an initial value of 0 + // Describe what line 3 is doing, in particular focus on what = is doing + + + +Line 1 is a declaration and Line 3 is a statement that changes the value of the variable 'count' by adding 1 to its current value. +The variable is changing from 0 to 1 after line 3 is executed after we used 'let' to declare the variable 'count' and then we used the = operator to assign the new value. \ No newline at end of file From 7dc9303ba139d55629f073139cf32f9248cb0bcf Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Sat, 19 Sep 2026 15:34:36 +0100 Subject: [PATCH 02/17] char.At for first, middle, last name and index. & added console.log --- Sprint-2/1-key-exercises/2-initials.js | 10 +++++++++- 1 file changed, 9 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..863666ecf 100644 --- a/Sprint-2/1-key-exercises/2-initials.js +++ b/Sprint-2/1-key-exercises/2-initials.js @@ -5,6 +5,14 @@ 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 = ``; // https://www.google.com/search?q=get+first+character+of+string+mdn + + +const initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0); + +console.log (initials); + + + From 050721b9cac9e5237cf5baedff15f5267c305c96 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Sun, 20 Sep 2026 22:36:44 +0100 Subject: [PATCH 03/17] slice method to store ext part of the variable --- Sprint-2/1-key-exercises/3-paths.js | 6 ++++-- 1 file changed, 4 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..199696d08 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -17,7 +17,9 @@ 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(1, lastSlashIndex); + +const ext = base.slice(45); + // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 67e2dffc15951c8d0e64d692142ddb17041bbdf2 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 01:05:04 +0100 Subject: [PATCH 04/17] Explained what num represents. --- Sprint-2/1-key-exercises/4-random.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Sprint-2/1-key-exercises/4-random.js b/Sprint-2/1-key-exercises/4-random.js index 292f83aab..d4a0ecd0c 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -3,7 +3,25 @@ const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; +console.log(num); + + // In this exercise, you will need to work out what num represents? // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing + +Num represents a random whole number between the value of 'minimum' (1) and 'maximum' (100) +By creating a constant variable called 'num' and assigning it the value of the expression, we can generate a random number within the mentioned range. + +When running the program we have to understand how the expression works: + +we have to work out the parentheses first, maximum - minimum + 1, which is equal to 100 - 1 + 1 = 100. +so: Math.floor(Math.random() *100) + 1 + Math.random() produces a pseudo-random decimal number that is greater than or equal to 0 but less than 1. + + Next, we need to multiply the result from Math.random() by 100. This may give us the result of a decimal between 0 and 100. + Next step is to use Math.floor() wich then rounds down the decimal number to the nearest whole integer. This then means that the result will be a whole number between 0 and 99. +But we want 1-100, so we add 1 to the result of Math.floor() this then changes the range to be inclusive of 1 and 100. +After adding 1, we need to round down the number to the nearest interger, this is done by using Math.floor(). After this we will have a whole number between maximum and minimum. +Therefore, the final result of num will be a random whole number between 1 and 100, inclusive. From 8380925fe2363fef4896ce834f1b872c8ce5f683 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 01:16:44 +0100 Subject: [PATCH 05/17] // to not run line --- Sprint-2/2-mandatory-errors/0.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index cf6c5039f..8e6242e15 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,2 +1,6 @@ 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 +We don't +// want the computer to run these 2 lines - how can we solve this problem? + +We can add 2 forward slashes , by typing two forward slashes ( // ) at the beginning of the line, we can turn that line into a comment. This then means that the computer will completely ignore that line and not run it. + \ No newline at end of file From 1c653d15ffe83d272cebd9e574b10caf871855ff Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 01:35:57 +0100 Subject: [PATCH 06/17] using 'let' to reassign the value --- Sprint-2/2-mandatory-errors/1.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/1.js b/Sprint-2/2-mandatory-errors/1.js index 7a43cbea7..f5ac398d5 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -1,4 +1,15 @@ // trying to create an age variable and then reassign the value by 1 - -const age = 33; +let age= 33; age = age + 1; + +console.log (age); + + + +const means that the variable age is a constant and cannot be reassigned. When we try to reassign the value of age by adding 1 to it, we get an error. +This is because we cannot change the value of a constant variable once we have created it. + +If we want to change the value of age, we need to use let instead of consts when declaring the variable. this then allows us to reassign the value of age by adding 1 to it. + + + From 1a7c56f33ff78ddebe65705bdccb3af495206d1a Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 02:52:25 +0100 Subject: [PATCH 07/17] fixed error order --- Sprint-2/2-mandatory-errors/2.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index e09b89831..ae316b8d2 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,5 +1,17 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? +error + console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +The reason there is an error is because we are using the wrong order, we are telling Javascript to print the value of cityOfBirth before creating a variable. +So we need to create the variable first, this is because Javascript runs code from top to bottom, so a variable that is declared with const needs to be declared before using it. + + + +right way + +const cityOfBirth = "Bolton"; +console.log (`I was born in ${cityOfBirth}`); \ No newline at end of file From e325f3ccc0423cc3b92d41f65473d5227bcf0f7f Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 03:24:22 +0100 Subject: [PATCH 08/17] change number to string to use the .slice method and fix error --- Sprint-2/2-mandatory-errors/3.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index ec101884d..9af740e87 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,16 @@ 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); + +I think that Javascript will give an error because .slice() is normally used with strings, and cardNumber is currently a number. +const cardNumber = 4533787178994213; does not have any quotation marks, so Javascript will treat it as a number. + +When run with console.log(last4Digits); we get --> TypeError : cardNumber.slice is not a function + +.slice is a method used with strings and we need to make cardNumber into a string by adding quotation marks.I + +const cardNumber = 4533787178994213 to const cardNumber = "4533787178994213"; +Now cardNumber is a string, then we can re run the code with console.log(last4Digits); to get the correct code. \ No newline at end of file From 9f4f143e680bfb40c0ee1f5e6a7d49a8568e47d6 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 03:38:24 +0100 Subject: [PATCH 09/17] variables unable to start with a number, caused syntaxerror --- Sprint-2/2-mandatory-errors/4.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-errors/4.js b/Sprint-2/2-mandatory-errors/4.js index 5f86c730b..11ee8292c 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -1,2 +1,12 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const Hour12ClockTime = "8:53pm"; + +console.log(Hour12ClockTime); + +const hour24ClockTime = "20:53"; + +console.log(hour24ClockTime); + + + + +Variable names cannot start with a number as Javascript doesnt allow it, it can contan number inside the variable but not at the beginning. From bba3df367f8246b3bc2687665885c13d78061f9f Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 10:19:54 +0100 Subject: [PATCH 10/17] answered questions --- Sprint-2/3-mandatory-interpret/1-percentage-change.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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..2b7518e2f 100644 --- a/Sprint-2/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-2/3-mandatory-interpret/1-percentage-change.js @@ -12,11 +12,13 @@ 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, two function calls on line 4 = Number(...) and replaceAll(...) two more on line 5 = Number(...) and replaceAll(...) and finally on line 10 = 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? - +SyntaxError: missing a comma to separate the arguments // c) Identify all the lines that are variable reassignment statements - +carPrice = Number(carPrice.replaceAll(",", "")); and priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // d) Identify all the lines that are variable declarations - +There are 4 variable declarations- 1) let carPrice = "10,000"; 2) let priceAfterOneYear = "8,543"; +3) const priceDifference = carPrice-priceAfterOneYear; 4) const percentageChange = (priceDifferenc/carPrice)* 100; // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +Number(carPrice.replaceAll(",", "")); is a string and the expression removes the comma from "10,000" and converts "10000" from a string into the number 10000. \ No newline at end of file From e556d1d75164c74e9eef07b4a847a297e8d1d1ad Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 12:40:34 +0100 Subject: [PATCH 11/17] code tested, answered questions --- Sprint-2/3-mandatory-interpret/2-time-format.js | 14 ++++++++++---- 1 file changed, 10 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 47d239558..6b8b7428b 100644 --- a/Sprint-2/3-mandatory-interpret/2-time-format.js +++ b/Sprint-2/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,20 @@ 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 variable Declarations, every const creates a new variable. // b) How many function calls are there? - +1 function calls is console.log() as it is a function being called and told to do the job // c) Using documentation, explain what the expression movieLength % 60 represents // 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? +movieLength % 60 means finding the remainder after dividing movieLength by 60. movieLength = 8784 so we need to do: 8784 % 60 = 146.4 and the nearest whole integer is 146. +So there are 146 complete groups of 60. we then multiply; 146 x 60= 8760 --> 8784 - 8760 = 24 so 8784 % 60 = 24 and therefore remainingSeconds becomes 24. +// d) Interpret line 4, what does the expression assigned to totalMinutes mean? +const totalMinutes = (movieLength - remainingSeconds) / 60 ---> if we break it down -> movieLength = 8784 remainingSeconds = 24 +we then subtract remainingSeconds from movieLength= 8784 -24 = 8670. we then have to divide it by 60 which gives us 8760 / 60 = 146. we divide because there is 60 seconds in one minute, and right now we are converting seconds into minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? - +The result variable will show us he complete results from our calculations of = totalHours:remainingMinutes:remainingSeconds. +result = 2:26:24 // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +I tested differnet codes: 7965 and I got the result 2:12:45 and i also tried : 2654 and got 0:44:14. \ No newline at end of file From 9781f22990dbcf6164b47f308f296c34778192d5 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 14:48:56 +0100 Subject: [PATCH 12/17] explained step by step breakdown of each line --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 13 +++++++++++++ 1 file changed, 13 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..a3320d06b 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -21,7 +21,20 @@ console.log(`£${pounds}.${pence}`); // The program then builds up a string representing the price in pounds // You need to do a step-by-step breakdown of each line in this program + // 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" +const penceString = "399p"; creates a variable. This string represents a price in pence. +We then count the variable penceString using index starting from 0 and ending at 3. +.length tells us how many characters there are in a string which in this case its 4. +Because we know penceString = 4 we have to then subtract 4-1=3.---> we have penceString.length-1 which then becomes 4 - 1 = 3. +we are doing this so we can remove the final character. +penceString.substring(0, 3) will give us "399" +padStart() adds characters to the beginning of a string until it reaches a certain length, we asked for a length of 3. +The final two characters represents pence and we are trying to get poundsright now.Because we have "399" and the last two digits represents pence and the character before that represents pounds. +we are subtracting 2 because when using substringwe remove the part that belongs to pence, 3 | 99 +padEnd count at the position of the last two digits and take everything after that so we can get the right value for pence. +here we are making sure that pence has 2 characters- this generally means that if the string does not add to 2 characters, add 0 to the end until its 2 characters Long +console.log displays something in the console as the backticks create a template literal inside it we put our variables. From 082f415a0895e67f3f428871223f4ef97ac03467 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 16:19:32 +0100 Subject: [PATCH 13/17] explained and used chrome console for alert and prompt function --- Sprint-2/4-stretch-explore/chrome.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sprint-2/4-stretch-explore/chrome.md b/Sprint-2/4-stretch-explore/chrome.md index 962580b82..95e05758f 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -8,8 +8,17 @@ 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? +alert is a function name and we are storing Hello world! as the argument. alert then alerts the screen with a banner with chrome url that says "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`. +when using prompt and input the argument "what is your name?" and press enter we get a text box where it asks for your name(because of the variable) and a cancel and ok button. you input the question, the function is what prompt() gives back and that is the return value. + What effect does calling the `prompt` function have? + +the prompt function displays a pop-up input box asking "what is your name?" prompt asks a question and users give an input and the prompt then returns that input. + + What is the return value of `prompt`? + +we need to create a variable first ' const myName = prompt ("what is your name?"); that stores the returned value in the variable. \ No newline at end of file From c1a4b08a8728a892bc07d862ffc7d8c9d562dd11 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Mon, 21 Sep 2026 16:52:52 +0100 Subject: [PATCH 14/17] answered questions about objects --- Sprint-2/4-stretch-explore/objects.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sprint-2/4-stretch-explore/objects.md b/Sprint-2/4-stretch-explore/objects.md index 0216dee56..6ea010a41 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -6,11 +6,27 @@ Open the Chrome devtools Console, type in `console.log` and then hit enter What output do you get? +it showed the log function rather than calling it f log() { [natice code]} + Now enter just `console` in the Console, what output do you get back? +the console objects and properties/functions ie, {debug:f, error:f, info:f, log:f, warn:f,...} + Try also entering `typeof console` +we get 'object' why?--> because console is an 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? + +console is an object that contains properties/functions used to interact with chrome/browser developer console. + +What does the syntax `console.log` or `console.assert` mean? + +console.log = access the log property inside the console object. +console.assert = access the assert property inside the console object. + +In particular, what does the `.` mean? + +The dot . is called the property accessor operator used to access an object's property. It also tells Javascript to go inside this object and get a particular property. From f18d99cec1b55277ba7a8397ffdca24d14a01301 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Tue, 22 Sep 2026 20:17:40 +0100 Subject: [PATCH 15/17] root is part of dir; fixed the mistake index starts at 0 --- Sprint-2/1-key-exercises/3-paths.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 199696d08..4bd86ca94 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 = filePath.slice(1, lastSlashIndex); +const dir = filePath.slice(0, lastSlashIndex); + const ext = base.slice(45); From 4f047d6b27b567e4a70b55b18d1f8a3462373da5 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Tue, 22 Sep 2026 20:17:51 +0100 Subject: [PATCH 16/17] // so it does not run code --- Sprint-2/3-mandatory-interpret/3-to-pounds.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Sprint-2/3-mandatory-interpret/3-to-pounds.js b/Sprint-2/3-mandatory-interpret/3-to-pounds.js index a3320d06b..71d1eed94 100644 --- a/Sprint-2/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-2/3-mandatory-interpret/3-to-pounds.js @@ -26,15 +26,15 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with // 1. const penceString = "399p": initialises a string variable with the value "399p" -const penceString = "399p"; creates a variable. This string represents a price in pence. -We then count the variable penceString using index starting from 0 and ending at 3. -.length tells us how many characters there are in a string which in this case its 4. -Because we know penceString = 4 we have to then subtract 4-1=3.---> we have penceString.length-1 which then becomes 4 - 1 = 3. -we are doing this so we can remove the final character. -penceString.substring(0, 3) will give us "399" -padStart() adds characters to the beginning of a string until it reaches a certain length, we asked for a length of 3. -The final two characters represents pence and we are trying to get poundsright now.Because we have "399" and the last two digits represents pence and the character before that represents pounds. -we are subtracting 2 because when using substringwe remove the part that belongs to pence, 3 | 99 -padEnd count at the position of the last two digits and take everything after that so we can get the right value for pence. -here we are making sure that pence has 2 characters- this generally means that if the string does not add to 2 characters, add 0 to the end until its 2 characters Long -console.log displays something in the console as the backticks create a template literal inside it we put our variables. +//const penceString = "399p"; creates a variable. This string represents a price in pence. +//We then count the variable penceString using index starting from 0 and ending at 3. +//.length tells us how many characters there are in a string which in this case its 4. +//Because we know penceString = 4 we have to then subtract 4-1=3.---> we have penceString.length-1 which then becomes 4 - 1 = 3. +//we are doing this so we can remove the final character. +//penceString.substring(0, 3) will give us "399" +//padStart() adds characters to the beginning of a string until it reaches a certain length, we asked for a length of 3. +//The final two characters represents pence and we are trying to get poundsright now.Because we have "399" and the last two digits represents pence and the character before that represents pounds. +//we are subtracting 2 because when using substringwe remove the part that belongs to pence, 3 | 99 +//padEnd count at the position of the last two digits and take everything after that so we can get the right value for pence. +//here we are making sure that pence has 2 characters- this generally means that if the string does not add to 2 characters, add 0 to the end until its 2 characters Long +//console.log displays something in the console as the backticks create a template literal inside it we put our variables. From f738b2fc687ac98886ba6b4bac1969e66f178a84 Mon Sep 17 00:00:00 2001 From: Sakiya Mayow Date: Tue, 22 Sep 2026 22:30:42 +0100 Subject: [PATCH 17/17] fixed feedback mistakes --- Sprint-2/1-key-exercises/1-count.js | 4 +-- Sprint-2/1-key-exercises/3-paths.js | 6 +++- Sprint-2/1-key-exercises/4-random.js | 31 ++++++++++--------- Sprint-2/2-mandatory-errors/0.js | 7 +++-- Sprint-2/2-mandatory-errors/1.js | 6 ++-- Sprint-2/2-mandatory-errors/2.js | 12 +++---- Sprint-2/2-mandatory-errors/3.js | 14 +++++---- Sprint-2/2-mandatory-errors/4.js | 2 +- .../1-percentage-change.js | 20 +++++++----- .../3-mandatory-interpret/2-time-format.js | 29 +++++++++++------ Sprint-2/4-stretch-explore/chrome.md | 9 +++--- Sprint-2/4-stretch-explore/objects.md | 12 +++---- 12 files changed, 89 insertions(+), 63 deletions(-) diff --git a/Sprint-2/1-key-exercises/1-count.js b/Sprint-2/1-key-exercises/1-count.js index 3efd03370..ab6dca720 100644 --- a/Sprint-2/1-key-exercises/1-count.js +++ b/Sprint-2/1-key-exercises/1-count.js @@ -8,5 +8,5 @@ count = count + 1; -Line 1 is a declaration and Line 3 is a statement that changes the value of the variable 'count' by adding 1 to its current value. -The variable is changing from 0 to 1 after line 3 is executed after we used 'let' to declare the variable 'count' and then we used the = operator to assign the new value. \ No newline at end of file +//Line 1 is a declaration and Line 3 is a statement that changes the value of the variable 'count' by adding 1 to its current value. +//The variable is changing from 0 to 1 after line 3 is executed after we used 'let' to declare the variable 'count' and then we used the = operator to assign the new value. \ No newline at end of file diff --git a/Sprint-2/1-key-exercises/3-paths.js b/Sprint-2/1-key-exercises/3-paths.js index 4bd86ca94..db5bd2b2f 100644 --- a/Sprint-2/1-key-exercises/3-paths.js +++ b/Sprint-2/1-key-exercises/3-paths.js @@ -19,8 +19,12 @@ console.log(`The base part of ${filePath} is ${base}`); const dir = filePath.slice(0, lastSlashIndex); +const ext = base.slice(base.lastIndexOf(".")); + + +console.log(dir); +console.log(ext); -const ext = base.slice(45); // 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 d4a0ecd0c..6d0cbf0c0 100644 --- a/Sprint-2/1-key-exercises/4-random.js +++ b/Sprint-2/1-key-exercises/4-random.js @@ -11,17 +11,20 @@ console.log(num); // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing -Num represents a random whole number between the value of 'minimum' (1) and 'maximum' (100) -By creating a constant variable called 'num' and assigning it the value of the expression, we can generate a random number within the mentioned range. - -When running the program we have to understand how the expression works: - -we have to work out the parentheses first, maximum - minimum + 1, which is equal to 100 - 1 + 1 = 100. -so: Math.floor(Math.random() *100) + 1 - Math.random() produces a pseudo-random decimal number that is greater than or equal to 0 but less than 1. - - Next, we need to multiply the result from Math.random() by 100. This may give us the result of a decimal between 0 and 100. - Next step is to use Math.floor() wich then rounds down the decimal number to the nearest whole integer. This then means that the result will be a whole number between 0 and 99. -But we want 1-100, so we add 1 to the result of Math.floor() this then changes the range to be inclusive of 1 and 100. -After adding 1, we need to round down the number to the nearest interger, this is done by using Math.floor(). After this we will have a whole number between maximum and minimum. -Therefore, the final result of num will be a random whole number between 1 and 100, inclusive. +//Num represents a random whole number between the value of 'minimum' (1) and 'maximum' (100) +//By creating a constant variable called 'num' and assigning it the value of the expression, we can generate a random number within the mentioned range. + +//When running the program we have to understand how the expression works: + +//we have to work out the parentheses first, maximum - minimum + 1, which is equal to 100 - 1 + 1 = 100. +//so: Math.floor(Math.random() *100) + 1 +// Math.floor is used 1 time and it happens before + minimum. Math.floor is used because when used Math.random() it produces a decimal number between 0 and 1. +//The code needs a whole number because we are trying to get a number between 1 and 100, this is where Math.floor comes () comes in and removes the decimal part. +//JavaScript works out the expression inside Math.floor () first before + minimum. + //Math.random() produces a pseudo-random decimal number that is greater than or equal to 0 but less than 1. + + //Next, we need to multiply the result from Math.random() by 100. This may give us the result of a decimal between 0 and 100. + //Next step is to use Math.floor() wich then rounds down the decimal number to the nearest whole integer. This then means that the result will be a whole number between 0 and 99. +//But we want 1-100, so we add 1 to the result of Math.floor() this then changes the range to be inclusive of 1 and 100. +//After adding 1, we need to round down the number to the nearest interger, this is done by using Math.floor(). After this we will have a whole number between maximum and minimum. +//Therefore, the final result of num will be a random whole number between 1 and 100, inclusive. diff --git a/Sprint-2/2-mandatory-errors/0.js b/Sprint-2/2-mandatory-errors/0.js index 8e6242e15..69734a30c 100644 --- a/Sprint-2/2-mandatory-errors/0.js +++ b/Sprint-2/2-mandatory-errors/0.js @@ -1,6 +1,7 @@ -This is just an instruction for the first activity - but it is just for human consumption -We don't +//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? -We can add 2 forward slashes , by typing two forward slashes ( // ) at the beginning of the line, we can turn that line into a comment. This then means that the computer will completely ignore that line and not run it. +//We can add 2 forward slashes , by typing two forward slashes ( // ) at the beginning of the line, we can turn both lines into a comment. This then means that the computer will completely ignore that line and not run it. \ 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 f5ac398d5..79b8d0138 100644 --- a/Sprint-2/2-mandatory-errors/1.js +++ b/Sprint-2/2-mandatory-errors/1.js @@ -6,10 +6,10 @@ console.log (age); -const means that the variable age is a constant and cannot be reassigned. When we try to reassign the value of age by adding 1 to it, we get an error. -This is because we cannot change the value of a constant variable once we have created it. +//const means that the variable age is a constant and cannot be reassigned. When we try to reassign the value of age by adding 1 to it, we get an error. +//This is because we cannot change the value of a constant variable once we have created it. -If we want to change the value of age, we need to use let instead of consts when declaring the variable. this then allows us to reassign the value of age by adding 1 to it. +//If we want to change the value of age, we need to use let instead of consts when declaring the variable. this then allows us to reassign the value of age by adding 1 to it. diff --git a/Sprint-2/2-mandatory-errors/2.js b/Sprint-2/2-mandatory-errors/2.js index ae316b8d2..67ddf13ce 100644 --- a/Sprint-2/2-mandatory-errors/2.js +++ b/Sprint-2/2-mandatory-errors/2.js @@ -1,17 +1,17 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? -error +//error -console.log(`I was born in ${cityOfBirth}`); -const cityOfBirth = "Bolton"; +//console.log(`I was born in ${cityOfBirth}`); +//const cityOfBirth = "Bolton"; -The reason there is an error is because we are using the wrong order, we are telling Javascript to print the value of cityOfBirth before creating a variable. -So we need to create the variable first, this is because Javascript runs code from top to bottom, so a variable that is declared with const needs to be declared before using it. +//The reason there is an error is because we are using the wrong order, we are telling Javascript to print the value of cityOfBirth before creating a variable. +//So we need to create the variable first, this is because Javascript runs code from top to bottom, so a variable that is declared with const needs to be declared before using it. -right way +//right way const cityOfBirth = "Bolton"; console.log (`I was born in ${cityOfBirth}`); \ No newline at end of file diff --git a/Sprint-2/2-mandatory-errors/3.js b/Sprint-2/2-mandatory-errors/3.js index 9af740e87..db220278d 100644 --- a/Sprint-2/2-mandatory-errors/3.js +++ b/Sprint-2/2-mandatory-errors/3.js @@ -11,12 +11,14 @@ const last4Digits = cardNumber.slice(-4); console.log(last4Digits); -I think that Javascript will give an error because .slice() is normally used with strings, and cardNumber is currently a number. -const cardNumber = 4533787178994213; does not have any quotation marks, so Javascript will treat it as a number. +//I think that Javascript will give an error because .slice() is normally used with strings, and cardNumber is currently a number. +//const cardNumber = 4533787178994213; does not have any quotation marks, so Javascript will treat it as a number. -When run with console.log(last4Digits); we get --> TypeError : cardNumber.slice is not a function +//When run with console.log(last4Digits); we get --> TypeError : cardNumber.slice is not a function -.slice is a method used with strings and we need to make cardNumber into a string by adding quotation marks.I +//.slice is a method used with strings and we need to make cardNumber into a string by adding quotation marks.I -const cardNumber = 4533787178994213 to const cardNumber = "4533787178994213"; -Now cardNumber is a string, then we can re run the code with console.log(last4Digits); to get the correct code. \ No newline at end of file +//we can change the expression by making it intoa string by doing --> const last4Digits = String(cardnumber).slice(-4); +//String(cardNumber) changes the number into a string and .slice(-4) takes the last 4 characters and stores it in last4Digits. +//const cardNumber = 4533787178994213 to const cardNumber = "4533787178994213"; +//Now cardNumber is a string, then we can re run the code with console.log(last4Digits); to get the correct code. \ 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 11ee8292c..59f3e4545 100644 --- a/Sprint-2/2-mandatory-errors/4.js +++ b/Sprint-2/2-mandatory-errors/4.js @@ -9,4 +9,4 @@ console.log(hour24ClockTime); -Variable names cannot start with a number as Javascript doesnt allow it, it can contan number inside the variable but not at the beginning. +//Variable names cannot start with a number as Javascript doesn't allow it, it can contain a number inside the variable but not at the beginning. diff --git a/Sprint-2/3-mandatory-interpret/1-percentage-change.js b/Sprint-2/3-mandatory-interpret/1-percentage-change.js index 2b7518e2f..be431ffac 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,13 +12,19 @@ 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, two function calls on line 4 = Number(...) and replaceAll(...) two more on line 5 = Number(...) and replaceAll(...) and finally on line 10 = console.log(...) + //> +// There are 5 function calls, two function calls on line 4 = Number(...) and replaceAll(...) two more on line 5 = Number(...) and replaceAll(...) and finally on line 10 = 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? -SyntaxError: missing a comma to separate the arguments + +//>SyntaxError: missing a comma to separate the arguments + // c) Identify all the lines that are variable reassignment statements -carPrice = Number(carPrice.replaceAll(",", "")); and priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); +//>carPrice = Number(carPrice.replaceAll(",", "")); and priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); + // d) Identify all the lines that are variable declarations -There are 4 variable declarations- 1) let carPrice = "10,000"; 2) let priceAfterOneYear = "8,543"; -3) const priceDifference = carPrice-priceAfterOneYear; 4) const percentageChange = (priceDifferenc/carPrice)* 100; +//>There are 4 variable declarations- 1) let carPrice = "10,000"; 2) let priceAfterOneYear = "8,543"; +//3) const priceDifference = carPrice-priceAfterOneYear; 4) const percentageChange = (priceDifferenc/carPrice)* 100; + // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? -Number(carPrice.replaceAll(",", "")); is a string and the expression removes the comma from "10,000" and converts "10000" from a string into the number 10000. \ No newline at end of file +//>Number(carPrice.replaceAll(",", "")); is a string and the expression removes the comma from "10,000" and converts "10000" from a string into the number 10000. \ 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 6b8b7428b..6f3764b36 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 = 90.5; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,20 +12,29 @@ 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 variable Declarations, every const creates a new variable. +//>6 variable Declarations, every const creates a new variable. + // b) How many function calls are there? -1 function calls is console.log() as it is a function being called and told to do the job +//>1 function calls is console.log() as it is a function being called and told to do the job + // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators -movieLength % 60 means finding the remainder after dividing movieLength by 60. movieLength = 8784 so we need to do: 8784 % 60 = 146.4 and the nearest whole integer is 146. -So there are 146 complete groups of 60. we then multiply; 146 x 60= 8760 --> 8784 - 8760 = 24 so 8784 % 60 = 24 and therefore remainingSeconds becomes 24. +//>movieLength % 60 means finding the remainder after dividing movieLength by 60. movieLength = 8784 so we need to do: 8784 % 60 = 146.4 and the nearest whole integer is 146. +//So there are 146 complete groups of 60. we then multiply; 146 x 60= 8760 --> 8784 - 8760 = 24 so 8784 % 60 = 24 and therefore remainingSeconds becomes 24. +//8784/60 = 146.4. and 8784 % 60 = 24 as this is the remainder. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? -const totalMinutes = (movieLength - remainingSeconds) / 60 ---> if we break it down -> movieLength = 8784 remainingSeconds = 24 -we then subtract remainingSeconds from movieLength= 8784 -24 = 8670. we then have to divide it by 60 which gives us 8760 / 60 = 146. we divide because there is 60 seconds in one minute, and right now we are converting seconds into minutes. +//>const totalMinutes = (movieLength - remainingSeconds) / 60 ---> if we break it down -> movieLength = 8784 remainingSeconds = 24 +//we then subtract remainingSeconds from movieLength= 8784 -24 = 8670. we then have to divide it by 60 which gives us 8760 / 60 = 146. we divide because there is 60 seconds in one minute, and right now we are converting seconds into minutes. + // e) What do you think the variable result represents? Can you think of a better name for this variable? -The result variable will show us he complete results from our calculations of = totalHours:remainingMinutes:remainingSeconds. -result = 2:26:24 +//>The result variable will show us he complete results from our calculations of = totalHours:remainingMinutes:remainingSeconds. +//result = 2:26:24 + // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer -I tested differnet codes: 7965 and I got the result 2:12:45 and i also tried : 2654 and got 0:44:14. \ No newline at end of file +//>I tested differnet codes: 7965 and I got the result 2:12:45 and i also tried : 2654 and got 0:44:14. + +//> suggestions to run code - 59 gives us 0:0:59 > less than 60 seconds +//-90 gives us 0:-1:-30 - not valid as the code works properly for non-negative whole numbers +//90.5 gives us 0:1:30.5 > this tells us 60 goes into 90.5 once and 30.5 is the remainder \ 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 95e05758f..0ae8eeb49 100644 --- a/Sprint-2/4-stretch-explore/chrome.md +++ b/Sprint-2/4-stretch-explore/chrome.md @@ -8,17 +8,18 @@ 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? -alert is a function name and we are storing Hello world! as the argument. alert then alerts the screen with a banner with chrome url that says "Hello world!" + +//alert is a function name and we are storing Hello world! as the argument. alert then alerts the screen with a banner with chrome url that says "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`. -when using prompt and input the argument "what is your name?" and press enter we get a text box where it asks for your name(because of the variable) and a cancel and ok button. you input the question, the function is what prompt() gives back and that is the return value. +//when using prompt and input the argument "what is your name?" and press enter we get a text box where it asks for your name(because of the variable) and a cancel and ok button. you input the question, the function is what prompt() gives back and that is the return value. What effect does calling the `prompt` function have? -the prompt function displays a pop-up input box asking "what is your name?" prompt asks a question and users give an input and the prompt then returns that input. +//the prompt function displays a pop-up input box asking "what is your name?" prompt asks a question and users give an input and the prompt then returns that input. What is the return value of `prompt`? -we need to create a variable first ' const myName = prompt ("what is your name?"); that stores the returned value in the variable. \ No newline at end of file +//we need to create a variable first ' const myName = prompt ("what is your name?"); that stores the returned value in the variable. \ 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 6ea010a41..2313af36c 100644 --- a/Sprint-2/4-stretch-explore/objects.md +++ b/Sprint-2/4-stretch-explore/objects.md @@ -6,27 +6,27 @@ Open the Chrome devtools Console, type in `console.log` and then hit enter What output do you get? -it showed the log function rather than calling it f log() { [natice code]} +//it showed the log function rather than calling it f log() { [natice code]} Now enter just `console` in the Console, what output do you get back? -the console objects and properties/functions ie, {debug:f, error:f, info:f, log:f, warn:f,...} +//the console objects and properties/functions ie, {debug:f, error:f, info:f, log:f, warn:f,...} Try also entering `typeof console` -we get 'object' why?--> because console is an object +//we get 'object' why?--> because console is an object Answer the following questions: What does `console` store? -console is an object that contains properties/functions used to interact with chrome/browser developer console. +//console is an object that contains properties/functions used to interact with chrome/browser developer console. What does the syntax `console.log` or `console.assert` mean? -console.log = access the log property inside the console object. +//console.log = access the log property inside the console object. console.assert = access the assert property inside the console object. In particular, what does the `.` mean? -The dot . is called the property accessor operator used to access an object's property. It also tells Javascript to go inside this object and get a particular property. +//The dot . is called the property accessor operator used to access an object's property. It also tells Javascript to go inside this object and get a particular property.