From 72a2114ad5b4b33ee3d725d1c7906f45756b3621 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Wed, 10 Jun 2026 19:36:52 +0100 Subject: [PATCH 01/40] add comment explaining what like 3 is doing --- Sprint-1/1-key-exercises/1-count.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..7c7f3e30e3 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,6 +1,7 @@ let count = 0; count = count + 1; - // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing +//Line 3 is updating variable count by adding 1 to its value. + From e9884937a0fa0637edebf8a6736508efcd53c523 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Wed, 10 Jun 2026 20:08:04 +0100 Subject: [PATCH 02/40] use string indexing to get the initials --- Sprint-1/1-key-exercises/2-initials.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f6175..bc26a8df4e 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,9 @@ 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[0]}${middleName[0]}${lastName[0]}`; // using string indexing to get the first character of +// each string +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From 541c57c40214786f3df4e647460f99d5a8bb62ed Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 12 Jun 2026 11:38:56 +0100 Subject: [PATCH 03/40] figure out what (num) represents, add comment --- Sprint-1/1-key-exercises/4-random.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..30e75bb5ac 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -2,8 +2,9 @@ const minimum = 1; const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; - +console.log(num); // In this exercise, you will need to work out what num represents? // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing +// num is a random number multiplied by the maximum number(100) plus 1. It is then rounded down to the nearest whole number using Math.floor. This means that num will be a random integer between 1 and 100, inclusive. From 2c05e7e2ace8b63058b1a0a1dd6585775f1b53be Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 12 Jun 2026 13:22:16 +0100 Subject: [PATCH 04/40] solve the slicing proble,create dir variabe and ext variable --- Sprint-1/1-key-exercises/3-paths.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..ed3ae829fe 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -16,8 +16,12 @@ 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(lastSlashIndex - 9, lastSlashIndex);//dir variable gets to "dir part of +// the path by using last instance of "/" as a reference and counting backwards 9 digits to get the beginning of the path +// and uses last instance of "/" as the end of the path, which is "interpret" +const ext = filePath.slice(lastSlashIndex + 5);// ext variable gets the last instance of "/" as a reference and +// counts 5 indexes forward to get the "ext" part of the path which is ".txt" +console.log(`The dir part of the filePath ${filePath} variable is "${dir}".`); +console.log(`The ext part of the filePath ${filePath} variable is "${ext}".`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 0a2e2ac91d49915e688451bd931d7ae423c756c5 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 12 Jun 2026 15:15:39 +0100 Subject: [PATCH 05/40] answer the question in the exercse --- Sprint-1/2-mandatory-errors/0.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f7..39f9e5bfba 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,3 @@ -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? +// we comment it out, this way the computer doesn't read is as code. From 697ddfc7597ed3b744ae48ec0d2c9adcd84e38bd Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 12 Jun 2026 15:21:55 +0100 Subject: [PATCH 06/40] change const to let, add comment --- Sprint-1/2-mandatory-errors/1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea76..d8a82f0720 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -1,4 +1,5 @@ // trying to create an age variable and then reassign the value by 1 -const age = 33; +let age = 33; // by changing the way we declare the variable from "const" to "let" we allow +// reassignment of the value of the variable age = age + 1; From 704b7178442f397270a9df22fd1eaa08cc7d3f16 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 12 Jun 2026 15:26:24 +0100 Subject: [PATCH 07/40] fix the error, comment on it --- Sprint-1/2-mandatory-errors/2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831d..d4317fc9b5 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -1,5 +1,5 @@ // Currently trying to print the string "I was born in Bolton" but it isn't working... // what's the error ? - -console.log(`I was born in ${cityOfBirth}`); +// The error was that the variable is not defined before the the console.log command. const cityOfBirth = "Bolton"; +console.log(`I was born in ${cityOfBirth}`); From 4c49b91b984f3975806a2f9d2edd1a9e666a716a Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sat, 13 Jun 2026 12:40:44 +0100 Subject: [PATCH 08/40] add question in comments --- Sprint-1/2-mandatory-errors/4.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 5f86c730bc..2b6fa83a8f 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,3 @@ const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; +const 24hourClockTime = "20:53"; +//what is the task in this exercise? From 600361180fa5641f8450e4162121c1b4a2145358 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 14 Jun 2026 16:02:35 +0100 Subject: [PATCH 09/40] fix problem --- Sprint-1/2-mandatory-errors/3.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884db..c97907ca94 100644 --- a/Sprint-1/2-mandatory-errors/3.js +++ b/Sprint-1/2-mandatory-errors/3.js @@ -1,5 +1,6 @@ -const cardNumber = 4533787178994213; +const cardNumber = "4533787178994213"; const last4Digits = cardNumber.slice(-4); +console.log(last4Digits); // The last4Digits variable should store the last 4 digits of cardNumber // However, the code isn't working @@ -7,3 +8,9 @@ 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 +// +// ------------------------Answer------------------------ +// Running the code did't meet my predictions. One, the most important thing I did't realize +// is that "slice() method only applies to strings and arrays, +// and the "cardNumber" variable was a number. By converting it to a string, the slice method +// is working correctly now." \ No newline at end of file From 06ed7a83e445acba99e3955ff62313926ca819c4 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 14 Jun 2026 16:16:30 +0100 Subject: [PATCH 10/40] answer all the questions in the exercise --- .../1-percentage-change.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e18..fd0e5c2c29 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -2,8 +2,7 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); - +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));// coma was missing. const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; @@ -12,11 +11,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 - +// Answer to a): There are 3 function calls in this file. +// // 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? - -// c) Identify all the lines that are variable reassignment statements - +// Answer to b): The error is coming from line 5, where coma is missing in "replaceAll()"" function. +// + //c) Identify all the lines that are variable reassignment statements +// Answer to c) Variables are reassigned on lines: 4 and 5 +// // d) Identify all the lines that are variable declarations - -// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// Answer to d) Variables are declared on lines: 1, 2, 6, 7 +// +// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - +// what is the purpose of this expression? +// Answer to e): The expression Number(carPrice.replaceAll(",","")) is replacing all the comas in the string in the variable +//carPrice with an empty string and then turns it into number. +// The purpose of it is that number can now be used to perform mathematical operations. \ No newline at end of file From a6d738adc991e9ca6cae0282556d3c8fb0c9c65b Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 15 Jun 2026 14:14:35 +0100 Subject: [PATCH 11/40] Answer questions in the exercise --- .../3-mandatory-interpret/2-time-format.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d2395587..1fd9480b2b 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -1,4 +1,4 @@ -const movieLength = 8784; // length of movie in seconds +const movieLength = -8784; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -12,14 +12,24 @@ 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 to a) There are six variables in this program. +// // b) How many function calls are there? - +// Answer to b) I think there one function call in this program and it is "console.log". +// // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators - +// Answer to c) The expression movieLength % 60 tels how many seconds will be left after +// full minutes are extracted. +// // d) Interpret line 4, what does the expression assigned to totalMinutes mean? - +// Answer to d) The line four calculates how many full minutes are in the movie. +// // 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 +// Answer to e) The variable result represents the total length of the movie in hours, minutes and seconds. +// A better name for this variable could be "formattedMovieLength". +// +// f) Try experimenting with different values of movieLength. Will this code work for all values of +// movieLength?Explain your answer +// Answer to f) This code will work with all values, however giving it a negative value will produce +// negative results. From c00ebcdc46a5b1dd1aeac16326a5332ab603d60c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 15 Jun 2026 16:07:57 +0100 Subject: [PATCH 12/40] add comments to explain code --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69a..90ad6c7d8c 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -1,4 +1,4 @@ -const penceString = "399p"; +const penceString = "33399p"; const penceStringWithoutTrailingP = penceString.substring( 0, @@ -6,6 +6,7 @@ const penceStringWithoutTrailingP = penceString.substring( ); const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2 @@ -24,4 +25,21 @@ 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" +// Line 1. const penceString = "399p": initialises a string variable with the value "399p" +// +// Line 3. variable "penceStringWithoutTrailingP" declared and assigned first three characters +// of "penceString" using the substring method, removing the trailing "p". +// +// Line 8 . variable "paddedPenceNumberString" declared and assigned the value of "penceStringWithoutTrailingP" +// padded to a minimum length of 3 characters with leading zeros using the padStart method. Which is clever way, +// really to replace it with zeros if number of pence is less than 3 characters long. +// +// Line 10 Variable "pounds" declared and assigned value of "paddedPenceNumberString" but without the last +// two characters. +// +// Line 15. Variable "pence" declared and assigned value of the last two characters of "paddedPenceNumberString" +// and padded to a minimum length of 2 characters with zeros at the end, padEnd method is used once again. +// it is to ensure that if the number of pence is less than 2 characters long, it will be padded with zeros +// at the end. +// +// Line 19. console.log is used to print final output. From c89d0c3667e47f12ece2d0f192622261b8663c7b Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 15 Jun 2026 21:14:00 +0100 Subject: [PATCH 13/40] can't undestand instructions --- Sprint-1/4-stretch-explore/chrome.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feafe..26cd571d86 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -11,8 +11,10 @@ In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; What effect does calling the `alert` function have? +I Don't get it, When you say an input string "Hello World" do you meaan as a parameter, do you mean it suppose to return "Hello World", or what ? Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. What effect does calling the `prompt` function have? What is the return value of `prompt`? +Is it suppose to prompt me? From c1f05144d740e4cb82f167291db55677a8c283d5 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 15 Jun 2026 21:42:41 +0100 Subject: [PATCH 14/40] answer questions in objects.md --- Sprint-1/4-stretch-explore/objects.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md index 0216dee56a..d59bab0789 100644 --- a/Sprint-1/4-stretch-explore/objects.md +++ b/Sprint-1/4-stretch-explore/objects.md @@ -14,3 +14,6 @@ Answer the following questions: What does `console` store? What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? + +Answer: I don't think 'console' itself stores anything. Variables store values. 'console' is an object. +'.' after the 'console' allows to add one of the methods like console.log() or console.clear() From 71235b3fa457a8b728467c3aa6e32304563a99a4 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Wed, 24 Jun 2026 11:55:10 +0100 Subject: [PATCH 15/40] solve the code error message --- Sprint-2/1-key-errors/0.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js index 653d6f5a07..1e1eff1496 100644 --- a/Sprint-2/1-key-errors/0.js +++ b/Sprint-2/1-key-errors/0.js @@ -1,7 +1,9 @@ // Predict and explain first... // =============> write your prediction here - -// call the function capitalise with a string input +// Well, I think the variable "str" is being declared twice, so the code will +// through an error message. +// +//call the function capitalise with a string input // interpret the error message and figure out why an error is occurring function capitalise(str) { @@ -10,4 +12,12 @@ function capitalise(str) { } // =============> write your explanation here +//The variable "str" has been used as a parameter for the capitalise function +//and also been declared again inside the function. I think if "let" is removed +//the code will work. // =============> write your new code here +function capitalise(str) { + str = `${str[0].toUpperCase()}${str.slice(1)}`; + return str; +} +console.log(capitalise("sorted")); From fa9854858b89ca09630d0004b87531df972b5671 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 11:24:18 +0100 Subject: [PATCH 16/40] fix proble, answer questions --- Sprint-2/1-key-errors/1.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js index f2d56151f4..fc17d83e49 100644 --- a/Sprint-2/1-key-errors/1.js +++ b/Sprint-2/1-key-errors/1.js @@ -1,20 +1,40 @@ // Predict and explain first... - // Why will an error occur when this program runs? // =============> write your prediction here - +// I think there will be an error as "decimalNumber" variable has already been declared as a parameter in +// "convertToPercentage" function +// // Try playing computer with the example to work out what is going on -function convertToPercentage(decimalNumber) { +/*function convertToPercentage(decimalNumber) { const decimalNumber = 0.5; const percentage = `${decimalNumber * 100}%`; return percentage; } -console.log(decimalNumber); +console.log(decimalNumber); */ // =============> write your explanation here +// =============Explanation =============== +// the "decimalNumber" variable is a local variable and can only be seen inside "convertToPercentage" function +// therefore when called outside the function it triggers "ReferenceError" // Finally, correct the code to fix the problem +// =========correction========= +// problem can be fixed by moving the variable declaration outside the function +// and making it global + // =============> write your new code here + +const decimalNumber = 0.5; +function convertToPercentage(decimalNumber) { + const percentage = `${decimalNumber * 100}%`; + + return percentage; +} + +console.log(decimalNumber); +console.log(convertToPercentage(decimalNumber)); + + From 4b743c8a159d10bbeccdbcd0d73d12a2ac11d02d Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 11:45:02 +0100 Subject: [PATCH 17/40] fix code, explain fix --- Sprint-2/1-key-errors/2.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index aad57f7cfe..72dc6469d4 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -1,20 +1,24 @@ - // Predict and explain first BEFORE you run any code... // this function should square any number but instead we're going to get an error // =============> write your prediction of the error here - -function square(3) { +//=========Prediction============= +// I think there will not be en error till we call the function. +/*function square(num) { return num * num; } - +console.log(square(5))*/ // =============> write the error message here - +// Unexpected number // =============> explain this error message here - +// I think it // Finally, correct the code to fix the problem - +// ===========correction========= +// to correct the code we need to introduce parameter as a variable, rather than a number. +// that way any number can be passed when function is called. // =============> write your new code here - - +function square(num) { + return num * num; +} +console.log(square(5)); From 491964011032ca712cd18375e5aa743a56b7817f Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 12:06:12 +0100 Subject: [PATCH 18/40] fix code, write explanation --- Sprint-2/2-mandatory-debug/0.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js index b27511b417..1ba0b3fa69 100644 --- a/Sprint-2/2-mandatory-debug/0.js +++ b/Sprint-2/2-mandatory-debug/0.js @@ -1,14 +1,25 @@ // Predict and explain first... // =============> write your prediction here - -function multiply(a, b) { +//===========Prediction======= +// I think the code will not produce the desired result as the function is not returning any value +/*function multiply(a, b) { console.log(a * b); } - console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); +console.log(multiply(3, 5)); +typeof(multiply(3, 4));*/ // =============> write your explanation here - +//===============Explanation========= +// The function itself prints out the result, but the result has no (type) as such and can not be used as +// a data type. +// // Finally, correct the code to fix the problem +//============correction============ +// To correct the code "return" needs to be introduced. // =============> write your new code here +function multiply(a, b) { + return (a * b); +} +console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); \ No newline at end of file From 6a9bf82336295b44e725c6f8a428c00189bc908d Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 12:25:25 +0100 Subject: [PATCH 19/40] explain and fix code --- Sprint-2/2-mandatory-debug/1.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js index 37cedfbcfd..b004510d9c 100644 --- a/Sprint-2/2-mandatory-debug/1.js +++ b/Sprint-2/2-mandatory-debug/1.js @@ -1,13 +1,23 @@ // Predict and explain first... // =============> write your prediction here - +// =============explanation========== +// I think will either give error, or no result at all as there is a ";" semicolon after +// the return statement and the actual calculation is not assigned to anything. function sum(a, b) { return; - a + b; + a + b; } console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // =============> write your explanation here +//==============Explanation=============== +//To fix the code the ";" must be removed, and the calculation +//needs to be placed next to the "return" // Finally, correct the code to fix the problem // =============> write your new code here +function sum(a, b) { + return a + b; +} + +console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); From 9560e8da8ab648f5476c382d9a36399cc6839d4e Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 12:48:07 +0100 Subject: [PATCH 20/40] explain and fix the code --- Sprint-2/2-mandatory-debug/2.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js index 57d3f5dc35..db1975ec80 100644 --- a/Sprint-2/2-mandatory-debug/2.js +++ b/Sprint-2/2-mandatory-debug/2.js @@ -2,6 +2,9 @@ // Predict the output of the following code: // =============> Write your prediction here +//============Prediction======== +// I think the code output will be "3" in al three cases as "num variable is declared outside the function and +// not used as a parameter for the function" const num = 103; @@ -14,11 +17,30 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`); console.log(`The last digit of 806 is ${getLastDigit(806)}`); // Now run the code and compare the output to your prediction +// prediction matched // =============> write the output here +/*The last digit of 42 is 3 +The last digit of 105 is 3 +The last digit of 806 is 3*/ // Explain why the output is the way it is // =============> write your explanation here +//===============Explanation=========== +// The variable is not used as a parameter of the function, and therefore +// is ignored when passed inside function call. // Finally, correct the code to fix the problem +// // =============> write your new code here +//const num = 103; +function getLastDigit(num) { + return num.toString().slice(-1); +} + +console.log(`The last digit of 42 is ${getLastDigit(42)}`); +console.log(`The last digit of 105 is ${getLastDigit(105)}`); +console.log(`The last digit of 806 is ${getLastDigit(806)}`); // This program should tell the user the last digit of each number. // Explain why getLastDigit is not working properly - correct the problem +// =============explanation================== +// The variable is not used as a parameter of the function, and therefore +// is ignored when passed inside function call. From 618704086d45ffbe243ca0aeb43a90e3b7dfc53e Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 15:21:37 +0100 Subject: [PATCH 21/40] create function to calculate BMI --- Sprint-2/3-mandatory-implement/1-bmi.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js index 17b1cbde1b..e0ea51ef82 100644 --- a/Sprint-2/3-mandatory-implement/1-bmi.js +++ b/Sprint-2/3-mandatory-implement/1-bmi.js @@ -13,7 +13,10 @@ // Given someone's weight in kg and height in metres // Then when we call this function with the weight and height // It should return their Body Mass Index to 1 decimal place - +// function calculateBMI(weight, height) { - // return the BMI of someone based off their weight and height -} \ No newline at end of file + let bmi = weight / (height **2 )// weight divided by height squared. + return `Your Body Mass Index is ${bmi.toFixed(1)} units`// toFixed(1) insures that result is displayed + // with 1 decimal point +} +console.log(calculateBMI(87, 1.86)) \ No newline at end of file From 82a2abd9c0228511e3b53c90b71e4f135a2ed3e3 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 25 Jun 2026 16:19:22 +0100 Subject: [PATCH 22/40] implement function for UPPER_SNAKE --- Sprint-2/3-mandatory-implement/2-cases.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js index 5b0ef77ad9..60c323d90c 100644 --- a/Sprint-2/3-mandatory-implement/2-cases.js +++ b/Sprint-2/3-mandatory-implement/2-cases.js @@ -14,3 +14,11 @@ // You will need to come up with an appropriate name for the function // Use the MDN string documentation to help you find a solution // This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase +// +function upper_snake_case(word) { + let new_word = word.toUpperCase();// capitalises string + let split_word = new_word.split(" ");// turns string into array in order to to use "join()" method + let joined_word = split_word.join("_")// joins strings with "_" to make it UPPER_SNAKE + return joined_word; +} +console.log(upper_snake_case("hello there")); From ca2e82e84c0dce6fad1742d6198779eb365dee1c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 26 Jun 2026 12:25:48 +0100 Subject: [PATCH 23/40] implement function to convert to pounds --- Sprint-2/3-mandatory-implement/3-to-pounds.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js index 6265a1a703..766e686374 100644 --- a/Sprint-2/3-mandatory-implement/3-to-pounds.js +++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js @@ -4,3 +4,37 @@ // You will need to declare a function called toPounds with an appropriately named parameter. // You should call this function a number of times to check it works for different inputs +function toPounds(penceString) { + const penceStringWithoutTrailingP = penceString.substring( + 0, + penceString.length - 1 + ); //variable + // "penceStringWithoutTrailingP" declared and assigned first three characters + // of "penceString" using the substring method, removing the trailing "p". + + const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + // variable "paddedPenceNumberString" declared and assigned the value of "penceStringWithoutTrailingP" + // padded to a minimum length of 3 characters with leading zeros using the padStart method. Which is clever way, + // really to replace it with zeros if number of pence is less than 3 characters long. + + const pounds = paddedPenceNumberString.substring( + 0, + paddedPenceNumberString.length - 2 + ); + //Variable "pounds" declared and assigned value of "paddedPenceNumberString" but without the last + // two characters. + + const pence = paddedPenceNumberString + .substring(paddedPenceNumberString.length - 2) + .padEnd(2, "0"); + // Variable "pence" declared and assigned value of the last two characters of "paddedPenceNumberString" + // and padded to a minimum length of 2 characters with zeros at the end, padEnd method is used once again. + // it is to ensure that if the number of pence is less than 2 characters long, it will be padded with zeros + // at the end. + + return `£${pounds}.${pence}`; + // Finally equivalent in "pounds" and "pence" is returned +} +console.log(toPounds("2345")); // testing with normal string of numbers +console.log(toPounds("-2345")); // testing with string of negative numbers +console.log(toPounds("0")); // testing with zero From c81c5df79d68e2beea26b0e9063878848ef0499e Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 28 Jun 2026 22:05:17 +0100 Subject: [PATCH 24/40] Answer questions --- Sprint-2/4-mandatory-interpret/time-format.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js index 17127bc01e..bad1313dc3 100644 --- a/Sprint-2/4-mandatory-interpret/time-format.js +++ b/Sprint-2/4-mandatory-interpret/time-format.js @@ -14,6 +14,7 @@ function formatTimeDisplay(seconds) { return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; } +console.log(formatTimeDisplay(61)) // You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit // to help you answer these questions @@ -22,17 +23,26 @@ function formatTimeDisplay(seconds) { // a) When formatTimeDisplay is called how many times will pad be called? // =============> write your answer here +// Answer to a) : when "formatTimeDisplay" is called "pad" is called 3 times // Call formatTimeDisplay with an input of 61, now answer the following: // b) What is the value assigned to num when pad is called for the first time? // =============> write your answer here +// Answer to b) : value assigned to num when pad is called for the first time is 0 - zero // c) What is the return value of pad is called for the first time? // =============> write your answer here +// Answer to c) : the return value on pad is the "numString" variable, which is string "00" // d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer // =============> write your answer here +// Answer to d) : Value assigned to "num" the last time "pad" is called is 1, one. +// "num" in this case is a variable "remainingSeconds", which is a remainder of "seconds" (61) +// variable divided by 60, which is 1. // e) What is the return value of pad when it is called for the last time in this program? Explain your answer // =============> write your answer here +// Answer to e) : The return value of "pad" the last time pad called is the variable "numString" +// which is - string "01". "toString" variable is a "num" converted to a string earlier in the function +// and makes it double digit string. From 301c8f1c86bbea27700c4bf0b199516d43267c86 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 29 Jun 2026 16:18:42 +0100 Subject: [PATCH 25/40] write tests, fix bugs --- Sprint-2/5-stretch-extend/format-time.js | 37 ++++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js index 32a32e66b8..f26699638d 100644 --- a/Sprint-2/5-stretch-extend/format-time.js +++ b/Sprint-2/5-stretch-extend/format-time.js @@ -1,15 +1,19 @@ // This is the latest solution to the problem from the prep. // Make sure to do the prep before you do the coursework -// Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find. +// Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any +// bugs you find. function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); - if (hours > 12) { - return `${hours - 12}:00 pm`; - } + if (Number(time.slice(0, 2)) === 12) { + return `${time} pm` // if time is "12:00" it will show + //12:00 pm + } else if (Number(time.slice(0, 2))=== 24) { + return `00:00 am`; + } else if (Number(time.slice(0, 2)) > 12) { + return `${Number(time.slice(0, 2)) - 12}:00 pm`; + } return `${time} am`; } - const currentOutput = formatAs12HourClock("08:00"); const targetOutput = "08:00 am"; console.assert( @@ -23,3 +27,24 @@ console.assert( currentOutput2 === targetOutput2, `current output: ${currentOutput2}, target output: ${targetOutput2}` ); +const currentOutput3 = formatAs12HourClock("00:00");// +const targetOutput3 = "00:00 am";// expecting new test to return "00:00 am" +console.assert( + currentOutput3 === targetOutput3, + `current output: ${currentOutput3}, target output: ${targetOutput3}` +); // if currentOutput3 and targetOutput3 do not match, the assertion message will be given. + +const currentOutput4 = formatAs12HourClock("12:00");// +const targetOutput4 = "12:00 pm"; // expected output for "12:00" is "12:00 pm" +console.assert( + currentOutput4 === targetOutput4, + `current output: ${currentOutput4}, target output: ${targetOutput4}` +);// if currentOutput and targetOutput do not match, the assertion message will be given. +const currentOutput5 = formatAs12HourClock("24:00"); +const targetOutput5 = "00:00 am"; +console.assert( + currentOutput5 === targetOutput5, + `current output5: ${currentOutput5}, target output5: ${targetOutput5}` + ); // if 24:00 is entered and the output is not "00:00 am" the assertion message will be given + + From 9ccd193baeb9e8c978b65d9fb4db59df454e2b0d Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 13:59:52 +0100 Subject: [PATCH 26/40] edit comment --- Sprint-2/1-key-errors/2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js index 72dc6469d4..91375fcf8f 100644 --- a/Sprint-2/1-key-errors/2.js +++ b/Sprint-2/1-key-errors/2.js @@ -12,7 +12,7 @@ console.log(square(5))*/ // =============> write the error message here // Unexpected number // =============> explain this error message here -// I think it +// I think it function expects parameter as a variable rather than a number. // Finally, correct the code to fix the problem // ===========correction========= // to correct the code we need to introduce parameter as a variable, rather than a number. From 3a491f5aba3cdfb1a163b7b9890fd3c141f56fdd Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:30:51 +0100 Subject: [PATCH 27/40] Delete Sprint-1/1-key-exercises/1-count.js --- Sprint-1/1-key-exercises/1-count.js | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Sprint-1/1-key-exercises/1-count.js diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js deleted file mode 100644 index 7c7f3e30e3..0000000000 --- a/Sprint-1/1-key-exercises/1-count.js +++ /dev/null @@ -1,7 +0,0 @@ -let count = 0; - -count = count + 1; -// Line 1 is a variable declaration, creating the count variable with an initial value of 0 -// Describe what line 3 is doing, in particular focus on what = is doing -//Line 3 is updating variable count by adding 1 to its value. - From 9c5bcd0adbf24285e9de240cc4f3563971ca7da6 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:32:04 +0100 Subject: [PATCH 28/40] Delete Sprint-1/4-stretch-explore/objects.md --- Sprint-1/4-stretch-explore/objects.md | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 Sprint-1/4-stretch-explore/objects.md diff --git a/Sprint-1/4-stretch-explore/objects.md b/Sprint-1/4-stretch-explore/objects.md deleted file mode 100644 index d59bab0789..0000000000 --- a/Sprint-1/4-stretch-explore/objects.md +++ /dev/null @@ -1,19 +0,0 @@ -## Objects - -In this activity, we'll explore some additional concepts that you'll encounter in more depth later on in the course. - -Open the Chrome devtools Console, type in `console.log` and then hit enter - -What output do you get? - -Now enter just `console` in the Console, what output do you get back? - -Try also entering `typeof console` - -Answer the following questions: - -What does `console` store? -What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? - -Answer: I don't think 'console' itself stores anything. Variables store values. 'console' is an object. -'.' after the 'console' allows to add one of the methods like console.log() or console.clear() From eb98abb7a6f66bdc0f6f4d9a5d823af4ec208ab7 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:32:56 +0100 Subject: [PATCH 29/40] Delete Sprint-1/4-stretch-explore/chrome.md --- Sprint-1/4-stretch-explore/chrome.md | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 Sprint-1/4-stretch-explore/chrome.md diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md deleted file mode 100644 index 26cd571d86..0000000000 --- a/Sprint-1/4-stretch-explore/chrome.md +++ /dev/null @@ -1,20 +0,0 @@ -Open a new window in Chrome, - -then locate the **Console** tab. - -Voila! You now have access to the [Chrome V8 Engine](https://www.cloudflare.com/en-gb/learning/serverless/glossary/what-is-chrome-v8/). -Just like the Node REPL, you can input JavaScript code into the Console tab and the V8 engine will execute it. - -Let's try an example. - -In the Chrome console, -invoke the function `alert` with an input string of `"Hello world!"`; - -What effect does calling the `alert` function have? -I Don't get it, When you say an input string "Hello World" do you meaan as a parameter, do you mean it suppose to return "Hello World", or what ? - -Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. - -What effect does calling the `prompt` function have? -What is the return value of `prompt`? -Is it suppose to prompt me? From 2d44b6466530fd96404d5ab10593b31310e3f360 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:35:09 +0100 Subject: [PATCH 30/40] Delete Sprint-1/2-mandatory-errors/2.js --- Sprint-1/2-mandatory-errors/2.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/2.js diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js deleted file mode 100644 index d4317fc9b5..0000000000 --- a/Sprint-1/2-mandatory-errors/2.js +++ /dev/null @@ -1,5 +0,0 @@ -// Currently trying to print the string "I was born in Bolton" but it isn't working... -// what's the error ? -// The error was that the variable is not defined before the the console.log command. -const cityOfBirth = "Bolton"; -console.log(`I was born in ${cityOfBirth}`); From ce208ae3e3a7e811033fccd05848f3a528b90785 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:35:50 +0100 Subject: [PATCH 31/40] Delete Sprint-1/2-mandatory-errors/4.js --- Sprint-1/2-mandatory-errors/4.js | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/4.js diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js deleted file mode 100644 index 2b6fa83a8f..0000000000 --- a/Sprint-1/2-mandatory-errors/4.js +++ /dev/null @@ -1,3 +0,0 @@ -const 12HourClockTime = "8:53pm"; -const 24hourClockTime = "20:53"; -//what is the task in this exercise? From e042ab72a4ad1e58d124846ef8de444f6e329601 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:43:58 +0100 Subject: [PATCH 32/40] Delete Sprint-1/1-key-exercises/2-initials.js --- Sprint-1/1-key-exercises/2-initials.js | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Sprint-1/1-key-exercises/2-initials.js diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js deleted file mode 100644 index bc26a8df4e..0000000000 --- a/Sprint-1/1-key-exercises/2-initials.js +++ /dev/null @@ -1,13 +0,0 @@ -let firstName = "Creola"; -let middleName = "Katherine"; -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[0]}${middleName[0]}${lastName[0]}`; // using string indexing to get the first character of -// each string -console.log(initials); - -// https://www.google.com/search?q=get+first+character+of+string+mdn - From 19f6b35ead43dcc7edea3e01fb642f1b9ab6706a Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:44:21 +0100 Subject: [PATCH 33/40] Delete Sprint-1/1-key-exercises/3-paths.js --- Sprint-1/1-key-exercises/3-paths.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 Sprint-1/1-key-exercises/3-paths.js diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js deleted file mode 100644 index ed3ae829fe..0000000000 --- a/Sprint-1/1-key-exercises/3-paths.js +++ /dev/null @@ -1,27 +0,0 @@ -// The diagram below shows the different names for parts of a file path on a Unix operating system - -// ┌─────────────────────┬────────────┐ -// │ dir │ base │ -// ├──────┬ ├──────┬─────┤ -// │ root │ │ name │ ext │ -// " / home/user/dir / file .txt " -// └──────┴──────────────┴──────┴─────┘ - -// (All spaces in the "" line should be ignored. They are purely for formatting.) - -const filePath = "/Users/mitch/cyf/Module-JS1/week-1/interpret/file.txt"; -const lastSlashIndex = filePath.lastIndexOf("/"); -const base = filePath.slice(lastSlashIndex + 1); -console.log(`The base part of ${filePath} is ${base}`); - -// 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(lastSlashIndex - 9, lastSlashIndex);//dir variable gets to "dir part of -// the path by using last instance of "/" as a reference and counting backwards 9 digits to get the beginning of the path -// and uses last instance of "/" as the end of the path, which is "interpret" -const ext = filePath.slice(lastSlashIndex + 5);// ext variable gets the last instance of "/" as a reference and -// counts 5 indexes forward to get the "ext" part of the path which is ".txt" -console.log(`The dir part of the filePath ${filePath} variable is "${dir}".`); -console.log(`The ext part of the filePath ${filePath} variable is "${ext}".`); - -// https://www.google.com/search?q=slice+mdn \ No newline at end of file From 2c2aeee1991fbf183a07e8cfe9c2934b24258f2c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:44:54 +0100 Subject: [PATCH 34/40] Delete Sprint-1/1-key-exercises/4-random.js --- Sprint-1/1-key-exercises/4-random.js | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Sprint-1/1-key-exercises/4-random.js diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js deleted file mode 100644 index 30e75bb5ac..0000000000 --- a/Sprint-1/1-key-exercises/4-random.js +++ /dev/null @@ -1,10 +0,0 @@ -const minimum = 1; -const maximum = 100; - -const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; -console.log(num); -// In this exercise, you will need to work out what num represents? -// Try breaking down the expression and using documentation to explain what it means -// It will help to think about the order in which expressions are evaluated -// Try logging the value of num and running the program several times to build an idea of what the program is doing -// num is a random number multiplied by the maximum number(100) plus 1. It is then rounded down to the nearest whole number using Math.floor. This means that num will be a random integer between 1 and 100, inclusive. From d43c9faa264711ce41895d3cf464f892db752913 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:45:16 +0100 Subject: [PATCH 35/40] Delete Sprint-1/2-mandatory-errors/1.js --- Sprint-1/2-mandatory-errors/1.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/1.js diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js deleted file mode 100644 index d8a82f0720..0000000000 --- a/Sprint-1/2-mandatory-errors/1.js +++ /dev/null @@ -1,5 +0,0 @@ -// trying to create an age variable and then reassign the value by 1 - -let age = 33; // by changing the way we declare the variable from "const" to "let" we allow -// reassignment of the value of the variable -age = age + 1; From b68e8ad3a5cd612e9a6d3ba66c27f016b15d7591 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:45:53 +0100 Subject: [PATCH 36/40] Delete Sprint-1/2-mandatory-errors/0.js --- Sprint-1/2-mandatory-errors/0.js | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/0.js diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js deleted file mode 100644 index 39f9e5bfba..0000000000 --- a/Sprint-1/2-mandatory-errors/0.js +++ /dev/null @@ -1,3 +0,0 @@ -//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 comment it out, this way the computer doesn't read is as code. From 712fb63366f2752fcca0abf82eff512a02f809ae Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:46:12 +0100 Subject: [PATCH 37/40] Delete Sprint-1/2-mandatory-errors/3.js --- Sprint-1/2-mandatory-errors/3.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Sprint-1/2-mandatory-errors/3.js diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js deleted file mode 100644 index c97907ca94..0000000000 --- a/Sprint-1/2-mandatory-errors/3.js +++ /dev/null @@ -1,16 +0,0 @@ -const cardNumber = "4533787178994213"; -const last4Digits = cardNumber.slice(-4); -console.log(last4Digits); - -// The last4Digits variable should store the last 4 digits of cardNumber -// However, the code isn't working -// Before running the code, make and explain a prediction about why the code won't work -// Then run the code and see what error it gives. -// Consider: Why does it give this error? Is this what I predicted? If not, what's different? -// Then try updating the expression last4Digits is assigned to, in order to get the correct value -// -// ------------------------Answer------------------------ -// Running the code did't meet my predictions. One, the most important thing I did't realize -// is that "slice() method only applies to strings and arrays, -// and the "cardNumber" variable was a number. By converting it to a string, the slice method -// is working correctly now." \ No newline at end of file From c10a299cac1263f1c08f0344b1d3ee736a7c02f7 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:46:39 +0100 Subject: [PATCH 38/40] Delete Sprint-1/3-mandatory-interpret/1-percentage-change.js --- .../1-percentage-change.js | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 Sprint-1/3-mandatory-interpret/1-percentage-change.js diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js deleted file mode 100644 index fd0e5c2c29..0000000000 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ /dev/null @@ -1,29 +0,0 @@ -let carPrice = "10,000"; -let priceAfterOneYear = "8,543"; - -carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));// coma was missing. -const priceDifference = carPrice - priceAfterOneYear; -const percentageChange = (priceDifference / carPrice) * 100; - -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 -// Answer to a): There are 3 function calls in this file. -// -// 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 to b): The error is coming from line 5, where coma is missing in "replaceAll()"" function. -// - //c) Identify all the lines that are variable reassignment statements -// Answer to c) Variables are reassigned on lines: 4 and 5 -// -// d) Identify all the lines that are variable declarations -// Answer to d) Variables are declared on lines: 1, 2, 6, 7 -// -// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - -// what is the purpose of this expression? -// Answer to e): The expression Number(carPrice.replaceAll(",","")) is replacing all the comas in the string in the variable -//carPrice with an empty string and then turns it into number. -// The purpose of it is that number can now be used to perform mathematical operations. \ No newline at end of file From 5a6b4c4fdf40d6d2cef0271792aba3347501e0c8 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:47:49 +0100 Subject: [PATCH 39/40] Delete Sprint-1/3-mandatory-interpret/2-time-format.js --- .../3-mandatory-interpret/2-time-format.js | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 Sprint-1/3-mandatory-interpret/2-time-format.js diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js deleted file mode 100644 index 1fd9480b2b..0000000000 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ /dev/null @@ -1,35 +0,0 @@ -const movieLength = -8784; // length of movie in seconds - -const remainingSeconds = movieLength % 60; -const totalMinutes = (movieLength - remainingSeconds) / 60; - -const remainingMinutes = totalMinutes % 60; -const totalHours = (totalMinutes - remainingMinutes) / 60; - -const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; -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 to a) There are six variables in this program. -// -// b) How many function calls are there? -// Answer to b) I think there one function call in this program and it is "console.log". -// -// c) Using documentation, explain what the expression movieLength % 60 represents -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators -// Answer to c) The expression movieLength % 60 tels how many seconds will be left after -// full minutes are extracted. -// -// d) Interpret line 4, what does the expression assigned to totalMinutes mean? -// Answer to d) The line four calculates how many full minutes are in the movie. -// -// e) What do you think the variable result represents? Can you think of a better name for this variable? -// Answer to e) The variable result represents the total length of the movie in hours, minutes and seconds. -// A better name for this variable could be "formattedMovieLength". -// -// f) Try experimenting with different values of movieLength. Will this code work for all values of -// movieLength?Explain your answer -// Answer to f) This code will work with all values, however giving it a negative value will produce -// negative results. From 8ccb9f5b45dedf772e1cadbb3278f9cd64c21d78 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 30 Jun 2026 21:48:23 +0100 Subject: [PATCH 40/40] Delete Sprint-1/3-mandatory-interpret/3-to-pounds.js --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 45 ------------------- 1 file changed, 45 deletions(-) delete mode 100644 Sprint-1/3-mandatory-interpret/3-to-pounds.js diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js deleted file mode 100644 index 90ad6c7d8c..0000000000 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ /dev/null @@ -1,45 +0,0 @@ -const penceString = "33399p"; - -const penceStringWithoutTrailingP = penceString.substring( - 0, - penceString.length - 1 -); - -const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); - -const pounds = paddedPenceNumberString.substring( - 0, - paddedPenceNumberString.length - 2 -); - -const pence = paddedPenceNumberString - .substring(paddedPenceNumberString.length - 2) - .padEnd(2, "0"); - -console.log(`£${pounds}.${pence}`); - -// This program takes a string representing a price in 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 -// Line 1. const penceString = "399p": initialises a string variable with the value "399p" -// -// Line 3. variable "penceStringWithoutTrailingP" declared and assigned first three characters -// of "penceString" using the substring method, removing the trailing "p". -// -// Line 8 . variable "paddedPenceNumberString" declared and assigned the value of "penceStringWithoutTrailingP" -// padded to a minimum length of 3 characters with leading zeros using the padStart method. Which is clever way, -// really to replace it with zeros if number of pence is less than 3 characters long. -// -// Line 10 Variable "pounds" declared and assigned value of "paddedPenceNumberString" but without the last -// two characters. -// -// Line 15. Variable "pence" declared and assigned value of the last two characters of "paddedPenceNumberString" -// and padded to a minimum length of 2 characters with zeros at the end, padEnd method is used once again. -// it is to ensure that if the number of pence is less than 2 characters long, it will be padded with zeros -// at the end. -// -// Line 19. console.log is used to print final output.