From 577235d63a7dcd9a466a5b8d04fe38c7b45f4f31 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Mon, 23 Feb 2026 19:58:58 +0000 Subject: [PATCH 01/16] decribed what line 3 is doing in count.js excercise --- Sprint-1/1-key-exercises/1-count.js | 5 +++++ prep/example.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 prep/example.js diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6..3dc06a012 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -4,3 +4,8 @@ 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 re-assigning the variable "count" with a new value that increases the previous value by 1 + +*/ diff --git a/prep/example.js b/prep/example.js new file mode 100644 index 000000000..435c0968a --- /dev/null +++ b/prep/example.js @@ -0,0 +1,12 @@ +// This are declarations +const firstName = "Jane"; +const lastName = "Doe"; +const yearOfBirth = 1971; +let currentYear =2026; + +//This are statements +currentYear++; + +const introduction = `Hi, my name is ${firstName} ${lastName}, I am ${currentYear - yearOfBirth} years old.`; //saving return values +console.log(introduction); + From 21aec41e429367b50bb7c92de54255e0dc7039ee Mon Sep 17 00:00:00 2001 From: marthak1 Date: Mon, 23 Feb 2026 20:41:58 +0000 Subject: [PATCH 02/16] created an output of string with initial CKJ, outputed in the console --- Sprint-1/1-key-exercises/2-initials.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/1-key-exercises/2-initials.js b/Sprint-1/1-key-exercises/2-initials.js index 47561f617..d55da2f24 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -6,6 +6,11 @@ let lastName = "Johnson"; // 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 firstNameInitials = firstName.charAt(0); +let middleNameInitials = middleName.charAt(0); +let lastNameInitials = lastName.charAt(0); +initials= `${firstNameInitials}${middleNameInitials}${lastNameInitials}` +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From 089f7cfdf18268a4faf35dde553346bc838f5de0 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Mon, 23 Feb 2026 22:48:24 +0000 Subject: [PATCH 03/16] create a var to store directory filePath and ext --- Sprint-1/1-key-exercises/3-paths.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28..c322f8e9a 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/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(0, lastSlashIndex); +const lastDotIndex = filePath.lastIndexOf("."); +const ext = filePath.slice(lastDotIndex); +console.log(`The dir filePath is ${dir} and the ext filePath is ${ext}`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file From 46a401bc6bd42e996e9b14f02f89b7fde34e7112 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 17:22:34 +0000 Subject: [PATCH 04/16] documented the evaluation of the code provided in 4-random.js file --- Sprint-1/1-key-exercises/4-random.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aab..06d03014e 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -7,3 +7,15 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; // Try breaking down the expression and using documentation to explain what it means // It will help to think about the order in which expressions are evaluated // Try logging the value of num and running the program several times to build an idea of what the program is doing + + +/* +num stores a random integer between minimum (1) and maximum (100), inclusive. + +Breakdown: +1. Math.random() generates a decimal number between 0 (inclusive) and 1 (exclusive). +2. Multiplying by (maximum - minimum + 1) scales the range to 0–100. +3. Math.floor() removes the decimal part, producing integers from 0–99. +4. Adding minimum shifts the range to 1–100. +*/ +console.log(num); From 97ad7703f120ae303e785fc25a23d7de1d8ab601 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 17:44:23 +0000 Subject: [PATCH 05/16] commented out the 2 lines in 0.js --- Sprint-1/2-mandatory-errors/0.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index cf6c5039f..9876db1d3 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,2 +1,5 @@ -This is just an instruction for the first activity - but it is just for human consumption -We don't want the computer to run these 2 lines - how can we solve this problem? \ No newline at end of file +// This is just an instruction for the first activity - but it is just for human consumption +// We don't want the computer to run these 2 lines - how can we solve this problem? +/* comment out any code you do not want the machine to run by add two forward slash to a single line comment +a single slash and a multiplication sign to both ends of a double line comment like this. +*/ \ No newline at end of file From 0aceeed0c4e28a9767e969a1308003aa37ffe633 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 20:10:53 +0000 Subject: [PATCH 06/16] interpreting 0.js syntaxerror --- Sprint-1/2-mandatory-errors/0.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/0.js b/Sprint-1/2-mandatory-errors/0.js index 9876db1d3..612eb3934 100644 --- a/Sprint-1/2-mandatory-errors/0.js +++ b/Sprint-1/2-mandatory-errors/0.js @@ -1,5 +1,21 @@ // This is just an instruction for the first activity - but it is just for human consumption // We don't want the computer to run these 2 lines - how can we solve this problem? -/* comment out any code you do not want the machine to run by add two forward slash to a single line comment -a single slash and a multiplication sign to both ends of a double line comment like this. + +//The error found when running the code-> SyntaxError: Unexpected identifier 'is'. +// syntax errors means the grammar rules of the language has not been applied. The instruction is written in plain english in a js file. It is not written in js syntax so js cannot parse it. + +// An identifier just means: +//A variable name +//A function name +// Or any word that isn’t a keyword +// So "is" is being treated like a variable name — and the parser wasn’t expecting one at that position. + +// //Solution: +/*In this case, comment out the code by adding two forward slashes to a single line comment or +a single slash and a multiplication sign to both ends of a double line comment like the one used for this comment. +Other solutions could be checking: +Missing quotes +Missing operator +Missing comma +Or misplaced word */ \ No newline at end of file From 0c3a7bf9a7d30c1e4253bd8f4411b5c76970df30 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 20:21:26 +0000 Subject: [PATCH 07/16] interpreted TypeError in 1.js file --- Sprint-1/2-mandatory-errors/1.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/1.js b/Sprint-1/2-mandatory-errors/1.js index 7a43cbea7..2dd5e4339 100644 --- a/Sprint-1/2-mandatory-errors/1.js +++ b/Sprint-1/2-mandatory-errors/1.js @@ -2,3 +2,7 @@ const age = 33; age = age + 1; + +//TypeError: Assignment to constant variable. +//what went wrong +//The program is trying to reassign a constant variable. In javascript a constant once assigned cannot be reassigned another value \ No newline at end of file From 5468f4391664f6af680ed0ba088f9cebf02532a2 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 21:21:44 +0000 Subject: [PATCH 08/16] interpreted ReferenceError in 2.js --- Sprint-1/2-mandatory-errors/2.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/2.js b/Sprint-1/2-mandatory-errors/2.js index e09b89831..7fb878394 100644 --- a/Sprint-1/2-mandatory-errors/2.js +++ b/Sprint-1/2-mandatory-errors/2.js @@ -3,3 +3,7 @@ console.log(`I was born in ${cityOfBirth}`); const cityOfBirth = "Bolton"; + +//ReferenceError: Cannot access 'cityOfBirth' before initialization +/* A lexical variable was accessed before it was initialized. This happens within any scope (global, module, function, or block) when variables declared with let or const are accessed before the place where they are declared has been executed +*/ \ No newline at end of file From 36ad414286aa5eb8ff8a85446487492ef1a77a37 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 22:21:02 +0000 Subject: [PATCH 09/16] interpreted TypeError of Number conversion in 3.js file --- Sprint-1/2-mandatory-errors/3.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/3.js b/Sprint-1/2-mandatory-errors/3.js index ec101884d..83625e797 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 last4Digits = cardNumber.slice(-4); +const last4Digits = cardNumber.toString().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,10 @@ 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 + +//TypeError: cardNumber.slice is not a function +//The Number type value stored in cardNumber does not a slice method +//slice methods only works with arrays, strings or objects that has a callable property named slice + +//Solution: Convert the number value to string +//Options: use a String Wrapper or toString method From 2e76b382498af7e89c580d50ce57e59d066ef43b Mon Sep 17 00:00:00 2001 From: marthak1 Date: Tue, 24 Feb 2026 22:25:51 +0000 Subject: [PATCH 10/16] fixed compile time indentifier error in 4.js file --- Sprint-1/2-mandatory-errors/4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-1/2-mandatory-errors/4.js b/Sprint-1/2-mandatory-errors/4.js index 21dad8c5d..f0ab94e12 100644 --- a/Sprint-1/2-mandatory-errors/4.js +++ b/Sprint-1/2-mandatory-errors/4.js @@ -1,2 +1,2 @@ -const 12HourClockTime = "20:53"; -const 24hourClockTime = "08:53"; \ No newline at end of file +const twelveHourClockTime = "20:53"; +const twentyFourHourClockTime = "08:53"; \ No newline at end of file From a5691d24ce531661489aefe9890748e4e7061886 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Wed, 25 Feb 2026 20:14:41 +0000 Subject: [PATCH 11/16] interpreted the expressions in 1-percentage-change.js file --- .../3-mandatory-interpret/1-percentage-change.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/1-percentage-change.js b/Sprint-1/3-mandatory-interpret/1-percentage-change.js index e24ecb8e1..816e41325 100644 --- a/Sprint-1/3-mandatory-interpret/1-percentage-change.js +++ b/Sprint-1/3-mandatory-interpret/1-percentage-change.js @@ -2,7 +2,7 @@ let carPrice = "10,000"; let priceAfterOneYear = "8,543"; carPrice = Number(carPrice.replaceAll(",", "")); -priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ,"")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; @@ -12,11 +12,22 @@ 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 +// Line 4 and 4 has two function calls Number() and replaceAll() +// - line 10 has a function 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? +// Line 5- +// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); +// ^^^ +// SyntaxError: missing ) after argument list // c) Identify all the lines that are variable reassignment statements +// carPrice an priceAfterOneYear - lines 4 and 5 // d) Identify all the lines that are variable declarations +//Lines - 1, 2, 7, 8 // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? +// replaceAll() removes all occurrence of commas from the string e.g "10,000" becomes "10000" and the Number() wrapper converts +// the string to number type; "10000" becomes 10000 + From 7d1a29ec45a5a40553dfb44b157d36060b864977 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Thu, 26 Feb 2026 17:58:09 +0000 Subject: [PATCH 12/16] interpreted the program in 2-time-formation.js file --- Sprint-1/3-mandatory-interpret/2-time-format.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d239558..65ab537f7 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -12,14 +12,25 @@ console.log(result); // For the piece of code above, read the code and then answer the following questions // a) How many variable declarations are there in this program? +// 6 // b) How many function calls are there? +// 1 // c) Using documentation, explain what the expression movieLength % 60 represents // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators +//Remainder operator. +//The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. +// It always takes the sign of the dividend. // d) Interpret line 4, what does the expression assigned to totalMinutes mean? +// The value stored in totalMinute is calculating the number of minutes that have elapsed in the movie by subtracting the remaining time from the total duration and converting seconds to minutes. // e) What do you think the variable result represents? Can you think of a better name for this variable? +//The variable result represents a formatted time string in the format HH:MM:SS. +// A better name would be "movieDurationDisplay", as these names more clearly describe the purpose and content of the variable. // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer +// No. Not for all possible values of movieLength, some EdgeCases are: +//1. when movieLength is of negative value, the maths produces negative time and its illogical for a movie duration +//2. if movieLength is not a number, its produces "NAN" and this breaks mathematically \ No newline at end of file From 4ad9366124966906e8d5af595fe39ae511161d11 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Thu, 26 Feb 2026 18:41:21 +0000 Subject: [PATCH 13/16] added another edgecase to time formatting --- Sprint-1/3-mandatory-interpret/2-time-format.js | 7 ++++--- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 65ab537f7..8f52fb2b2 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 = 9; // length of movie in seconds const remainingSeconds = movieLength % 60; const totalMinutes = (movieLength - remainingSeconds) / 60; @@ -6,7 +6,7 @@ const totalMinutes = (movieLength - remainingSeconds) / 60; const remainingMinutes = totalMinutes % 60; const totalHours = (totalMinutes - remainingMinutes) / 60; -const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; +const result = `${totalHours}:${String(remainingMinutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`; console.log(result); // For the piece of code above, read the code and then answer the following questions @@ -33,4 +33,5 @@ console.log(result); // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer // No. Not for all possible values of movieLength, some EdgeCases are: //1. when movieLength is of negative value, the maths produces negative time and its illogical for a movie duration -//2. if movieLength is not a number, its produces "NAN" and this breaks mathematically \ No newline at end of file +//2. if movieLength is not a number, its produces "NAN" and this breaks mathematically +//3. what if movieLength is less than 10? if movieLength is let say 9 , without proper formatting it will look like this 0:0:9 but with 0 padding it looks better like this 0:00:09 \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/3-to-pounds.js b/Sprint-1/3-mandatory-interpret/3-to-pounds.js index 60c9ace69..91b6efc28 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -24,4 +24,7 @@ console.log(`£${pounds}.${pence}`); // Try and describe the purpose / rationale behind each step // To begin, we can start with -// 1. const penceString = "399p": initialises a string variable with the value "399p" +/* 1. const penceString = "399p": initializes a string variable with the value "399p" + 2. const penceStringWithoutTrailingP = This stores the substring of penceString without a trailing p, so "399p" becomes "399" + 3. const paddedPenceNumberString= +*/ From 6b7a4ed26a0c3bdab6b69cbb42caee434e979dd1 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Thu, 26 Feb 2026 21:51:29 +0000 Subject: [PATCH 14/16] evalutated each line of code in 3-to-pounds.js file --- Sprint-1/3-mandatory-interpret/3-to-pounds.js | 8 ++++++-- 1 file changed, 6 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 91b6efc28..ece49e720 100644 --- a/Sprint-1/3-mandatory-interpret/3-to-pounds.js +++ b/Sprint-1/3-mandatory-interpret/3-to-pounds.js @@ -6,6 +6,7 @@ const penceStringWithoutTrailingP = penceString.substring( ); const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); + const pounds = paddedPenceNumberString.substring( 0, paddedPenceNumberString.length - 2 @@ -25,6 +26,9 @@ console.log(`£${pounds}.${pence}`); // To begin, we can start with /* 1. const penceString = "399p": initializes a string variable with the value "399p" - 2. const penceStringWithoutTrailingP = This stores the substring of penceString without a trailing p, so "399p" becomes "399" - 3. const paddedPenceNumberString= + 2. const penceStringWithoutTrailingP = This stores the substring of penceString by extracting all characters except the final p. It takes the substring from index 0 up to (but not including) the last character p, so "399p" becomes "399". This removes the unit symbol so only the numeric portion remains. + 3. const paddedPenceNumberString= This stores the value of penceStringWithoutTrailingP, padded to a total length of 3 characters by adding leading zeros where necessary. This guarantees there are always enough digits to separate pounds and pence correctly. + 4. const pounds= Stores the substring of paddedPenceNumberString from index 0 to the last 2 index. These leading digits represent the pound portion of the amount. + 5. const pence= Extracts the final two digits of the padded string to represent the pence portion. padEnd(2, "0") ensures that the pence value always contains exactly two digits. + 6. console.log(`£${pounds}.${pence}`); logs the value of pounds and pence into a formatted currency string using template literals */ From 4a965e566e188373188dd088ef327ede19ac4a86 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Thu, 26 Feb 2026 22:19:11 +0000 Subject: [PATCH 15/16] sprint 1 stretch activity --- Sprint-1/4-stretch-explore/chrome.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sprint-1/4-stretch-explore/chrome.md b/Sprint-1/4-stretch-explore/chrome.md index e7dd5feaf..f92906a81 100644 --- a/Sprint-1/4-stretch-explore/chrome.md +++ b/Sprint-1/4-stretch-explore/chrome.md @@ -9,10 +9,14 @@ Let's try an example. In the Chrome console, invoke the function `alert` with an input string of `"Hello world!"`; +alert("Hello world!"); -What effect does calling the `alert` function have? +What effect does calling the `alert` function have? +A popup modal appears with the String -> "Hello world!" Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`. +let myName = prompt("What is your name?"); -What effect does calling the `prompt` function have? -What is the return value of `prompt`? + +What effect does calling the `prompt` function have?A modal appears with the "What is your name?" with an input field to enter your name. The input is then stored in the variable myName +What is the return value of `prompt`? My name stored in the variable myName From 50cc867f85d7f3770787feb3c8345162600cc3f0 Mon Sep 17 00:00:00 2001 From: marthak1 Date: Thu, 26 Feb 2026 23:51:11 +0000 Subject: [PATCH 16/16] removed prep folder --- prep/example.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 prep/example.js diff --git a/prep/example.js b/prep/example.js deleted file mode 100644 index 435c0968a..000000000 --- a/prep/example.js +++ /dev/null @@ -1,12 +0,0 @@ -// This are declarations -const firstName = "Jane"; -const lastName = "Doe"; -const yearOfBirth = 1971; -let currentYear =2026; - -//This are statements -currentYear++; - -const introduction = `Hi, my name is ${firstName} ${lastName}, I am ${currentYear - yearOfBirth} years old.`; //saving return values -console.log(introduction); -