From c1063767aa812846d42c2189990eac0802b7e3a6 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 03:57:37 +0000 Subject: [PATCH 01/18] Sprint 1: start learning log --- Sprint-1/notes/learning-log.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Sprint-1/notes/learning-log.md diff --git a/Sprint-1/notes/learning-log.md b/Sprint-1/notes/learning-log.md new file mode 100644 index 0000000000..43fab0706a --- /dev/null +++ b/Sprint-1/notes/learning-log.md @@ -0,0 +1,13 @@ +# Sprint 1 — Learning Log + +## What I learned +- Started Sprint 1 exercises and set up coursework branch + +## Errors I hit and what they mean +- + +## Docs I used (links) +- + +## Questions for class +- \ No newline at end of file From 21f7d70f4e2902a4e2288dcb4fce17eebcdcf230 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 04:13:02 +0000 Subject: [PATCH 02/18] Sprint 1 exercises: explain assignment in 1-count.js --- Sprint-1/1-key-exercises/1-count.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index 117bcb2b6e..ea3bba9473 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -2,5 +2,10 @@ let count = 0; count = count + 1; +console.log(count); + // Line 1 is a variable declaration, creating the count variable with an initial value of 0 // Describe what line 3 is doing, in particular focus on what = is doing + +// Line 3 takes the current value of count (0), adds 1 to it, +// and assigns the result (1) back to the count variable using =. \ No newline at end of file From 39c0fc629c8638b100416f56a5086211a232b943 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 04:24:20 +0000 Subject: [PATCH 03/18] Sprint 1 exercises: complete 2-initials.js and log redeclaration error --- Sprint-1/1-key-exercises/2-initials.js | 11 ++++++++++- 1 file changed, 10 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..5144635ae0 100644 --- a/Sprint-1/1-key-exercises/2-initials.js +++ b/Sprint-1/1-key-exercises/2-initials.js @@ -5,7 +5,16 @@ 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 = ``; + +// Solution logic + +// We want to combine those characters into one string. + +// So we concatenate: + +let initials = firstName[0] + middleName[0] + lastName[0]; +console.log(initials); // https://www.google.com/search?q=get+first+character+of+string+mdn From df378aabe44e9695ef57293e6fe99c4c55837172 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 04:46:37 +0000 Subject: [PATCH 04/18] Sprint 1 exercises: complete 3-paths.js using slice and lastIndexOf --- Sprint-1/1-key-exercises/3-paths.js | 12 ++++++++++-- Sprint-1/notes/learning-log.md | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Sprint-1/1-key-exercises/3-paths.js b/Sprint-1/1-key-exercises/3-paths.js index ab90ebb28e..1076cacc4b 100644 --- a/Sprint-1/1-key-exercises/3-paths.js +++ b/Sprint-1/1-key-exercises/3-paths.js @@ -17,7 +17,15 @@ 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 = ; +//const ext = ; + +const dir = filePath.slice(0, lastSlashIndex); + +const lastDotIndex = filePath.lastIndexOf("."); +const ext = filePath.slice(lastDotIndex); + +console.log(`Dir: ${dir}`); +console.log(`Ext: ${ext}`); // https://www.google.com/search?q=slice+mdn \ No newline at end of file diff --git a/Sprint-1/notes/learning-log.md b/Sprint-1/notes/learning-log.md index 43fab0706a..976b978276 100644 --- a/Sprint-1/notes/learning-log.md +++ b/Sprint-1/notes/learning-log.md @@ -2,6 +2,7 @@ ## What I learned - Started Sprint 1 exercises and set up coursework branch +- Learned how to extract directory and extension from a file path using lastIndexOf and slice. ## Errors I hit and what they mean - From 58524cdb4cd14f73f06a8fa6e3a6c422bc06fc7d Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 05:15:44 +0000 Subject: [PATCH 05/18] Sprint 1 exercises: complete 4-random.js with explanation --- Sprint-1/1-key-exercises/4-random.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sprint-1/1-key-exercises/4-random.js b/Sprint-1/1-key-exercises/4-random.js index 292f83aabb..f6677159bb 100644 --- a/Sprint-1/1-key-exercises/4-random.js +++ b/Sprint-1/1-key-exercises/4-random.js @@ -3,7 +3,10 @@ const maximum = 100; const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; -// In this exercise, you will need to work out what num represents? -// 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 +console.log(num); + +// num is a random integer between 1 and 100 (inclusive). +// Math.random() returns a decimal in the range [0, 1). +// Multiplying by (maximum - minimum + 1) scales it to the size of the range. +// Math.floor(...) converts it to an integer. +// Adding minimum shifts the range to start at 1 instead of 0. \ No newline at end of file From 1dae459d7659598514ab255c68d2e7a67ed89b2f Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 21:15:28 +0000 Subject: [PATCH 06/18] Sprint 1 learning log update --- Sprint-1/notes/learning-log.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-1/notes/learning-log.md b/Sprint-1/notes/learning-log.md index 976b978276..61caf57c20 100644 --- a/Sprint-1/notes/learning-log.md +++ b/Sprint-1/notes/learning-log.md @@ -3,9 +3,11 @@ ## What I learned - Started Sprint 1 exercises and set up coursework branch - Learned how to extract directory and extension from a file path using lastIndexOf and slice. +- How Math.random(), Math.floor(), and arithmetic combine to generate a random integer in a range + + +## Errors I hit and what they mean## What I learned -## Errors I hit and what they mean -- ## Docs I used (links) - From c9913f573c72ce69d81ba70cd57ee915364c1759 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 21:33:28 +0000 Subject: [PATCH 07/18] Sprint 1 errors: explain 0.js syntax error --- Sprint-1/2-mandatory-errors/answers.md | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Sprint-1/2-mandatory-errors/answers.md diff --git a/Sprint-1/2-mandatory-errors/answers.md b/Sprint-1/2-mandatory-errors/answers.md new file mode 100644 index 0000000000..12573f8000 --- /dev/null +++ b/Sprint-1/2-mandatory-errors/answers.md @@ -0,0 +1,29 @@ +# Sprint 1 — Mandatory Errors (Explanations) + +## 0.js +- Error shown: +- Why it happens: +- MDN link (optional): +- Error shown: `SyntaxError: Unexpected identifier 'is'` on line 1. +- Why it happens: The file begins with plain English text that is not inside a comment or a quoted string. Node tries to interpret it as JavaScript code, but `This is ...` is not valid JS syntax, so parsing fails. +- MDN link (optional): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Unexpected_token + +## 1.js +- Error shown: +- Why it happens: +- MDN link (optional): + +## 2.js +- Error shown: +- Why it happens: +- MDN link (optional): + +## 3.js +- Error shown: +- Why it happens: +- MDN link (optional): + +## 4.js +- Error shown: +- Why it happens: +- MDN link (optional): \ No newline at end of file From 723da0ccc3189294ec23b661737dab66637bf6a2 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 21:40:28 +0000 Subject: [PATCH 08/18] Sprint 1 errors: explain 1.js const reassignment error --- Sprint-1/2-mandatory-errors/answers.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/answers.md b/Sprint-1/2-mandatory-errors/answers.md index 12573f8000..80a1909382 100644 --- a/Sprint-1/2-mandatory-errors/answers.md +++ b/Sprint-1/2-mandatory-errors/answers.md @@ -12,6 +12,9 @@ - Error shown: - Why it happens: - MDN link (optional): +- Error shown: `TypeError: Assignment to constant variable.` on line 4. +- Why it happens: The variable `age` was declared with `const`, which prevents reassignment. The statement `age = age + 1` attempts to update the value, causing the error. +- MDN link (optional): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const ## 2.js - Error shown: From 245bf0fe4882fdcf0f4cdaad8e32ec4b57eb7692 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 21:44:15 +0000 Subject: [PATCH 09/18] Sprint 1 errors: explain 2.js temporal dead zone error --- Sprint-1/2-mandatory-errors/answers.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/answers.md b/Sprint-1/2-mandatory-errors/answers.md index 80a1909382..afdd254431 100644 --- a/Sprint-1/2-mandatory-errors/answers.md +++ b/Sprint-1/2-mandatory-errors/answers.md @@ -20,6 +20,10 @@ - Error shown: - Why it happens: - MDN link (optional): +- Error shown: `ReferenceError: Cannot access 'cityOfBirth' before initialization`. +- Why it happens: The variable `cityOfBirth` is declared later in the file using `let` or `const`, but it is used before that declaration. JavaScript does not allow access to `let`/`const` variables before initialization (temporal dead zone). +- MDN link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init + ## 3.js - Error shown: From 4582d8065883466c93b2029c528df3918afe66eb Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 21:46:05 +0000 Subject: [PATCH 10/18] Sprint 1 errors: explain 3.js slice type error --- Sprint-1/2-mandatory-errors/answers.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-1/2-mandatory-errors/answers.md b/Sprint-1/2-mandatory-errors/answers.md index afdd254431..0319bbff2d 100644 --- a/Sprint-1/2-mandatory-errors/answers.md +++ b/Sprint-1/2-mandatory-errors/answers.md @@ -29,6 +29,13 @@ - Error shown: - Why it happens: - MDN link (optional): +### 3.js + +- Error shown: `TypeError: cardNumber.slice is not a function` +- Why it happens: The variable `cardNumber` is a number, and numbers do not have the `slice()` method. The `slice()` method is only available on strings and arrays. +- Concept: Methods depend on data types in JavaScript. +- MDN link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice + ## 4.js - Error shown: From 3430d65adcdd16fcfba443ea9f50887f1d98b4f8 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 21:49:21 +0000 Subject: [PATCH 11/18] Sprint 1 errors: explain 4.js identifier syntax error --- Sprint-1/2-mandatory-errors/answers.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sprint-1/2-mandatory-errors/answers.md b/Sprint-1/2-mandatory-errors/answers.md index 0319bbff2d..4417f3797c 100644 --- a/Sprint-1/2-mandatory-errors/answers.md +++ b/Sprint-1/2-mandatory-errors/answers.md @@ -40,4 +40,10 @@ ## 4.js - Error shown: - Why it happens: -- MDN link (optional): \ No newline at end of file +- MDN link (optional): +### 4.js + +- Error shown: `SyntaxError: Invalid or unexpected token` +- Why it happens: The variable name `12HourClockTime` starts with a number. JavaScript identifiers cannot begin with a digit, so the parser throws a syntax error. +- Concept: Variable naming rules (identifiers must start with a letter, `_`, or `$`) +- MDN link: https://developer.mozilla.org/en-US/docs/Glossary/Identifier \ No newline at end of file From e1e4a8507718f4996e2d1f0205e6cf13ba095f04 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 22:35:58 +0000 Subject: [PATCH 12/18] Sprint 1 interpret: notes for 1-percentage-change --- Sprint-1/3-mandatory-interpret/answers.md | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Sprint-1/3-mandatory-interpret/answers.md diff --git a/Sprint-1/3-mandatory-interpret/answers.md b/Sprint-1/3-mandatory-interpret/answers.md new file mode 100644 index 0000000000..c06b268fcb --- /dev/null +++ b/Sprint-1/3-mandatory-interpret/answers.md @@ -0,0 +1,66 @@ +# Sprint 1 — Mandatory Interpret (Notes) + +## 1-percentage-change.js +- What the program does: +- Inputs: +- Output: +- Unfamiliar syntax (with link): +- What I changed / why: + + +## 2-time-format.js +- What the program does: +- Inputs: +- Output: +- Unfamiliar syntax (with link): +- What I changed / why: + +## 3-to-pounds.js +- What the program does: +- Inputs: +- Output: +- Unfamiliar syntax (with link): +- What I changed / why: + + +## 1-percentage-change.js + +### a) How many function calls are there? +There are 5 function calls: +- Number(carPrice.replaceAll(",", "")) +- carPrice.replaceAll(",", "") +- Number(priceAfterOneYear.replaceAll(",", "")) +- priceAfterOneYear.replaceAll(",", "") +- console.log(...) + +--- + +### b) Where did the error occur and why? +The error occurred on the line: +priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); + +The replaceAll function was missing a comma between its arguments. The correct syntax requires two arguments: replaceAll(search, replacement). + +Fix: +priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); + +--- + +### c) Variable reassignment statements +- carPrice = Number(carPrice.replaceAll(",", "")) +- priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")) + +--- + +### d) Variable declarations +- let carPrice = "10,000" +- let priceAfterOneYear = "8,543" +- const priceDifference = carPrice - priceAfterOneYear +- const percentageChange = (priceDifference / carPrice) * 100 + +--- + +### e) What does Number(carPrice.replaceAll(",", "")) do? +First, replaceAll(",", "") removes commas from the string "10,000", producing "10000". +Then, Number(...) converts the string "10000" into the numeric value 10000. +This ensures arithmetic operations can be performed correctly. \ No newline at end of file From 096e7220c4db07f4b01b9f0fbcabcb60f38f5bfb Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 22:54:16 +0000 Subject: [PATCH 13/18] Sprint 1 interpret: complete 2-time-format --- Sprint-1/3-mandatory-interpret/answers.md | 52 ++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/answers.md b/Sprint-1/3-mandatory-interpret/answers.md index c06b268fcb..50a94c36db 100644 --- a/Sprint-1/3-mandatory-interpret/answers.md +++ b/Sprint-1/3-mandatory-interpret/answers.md @@ -63,4 +63,54 @@ priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); ### e) What does Number(carPrice.replaceAll(",", "")) do? First, replaceAll(",", "") removes commas from the string "10,000", producing "10000". Then, Number(...) converts the string "10000" into the numeric value 10000. -This ensures arithmetic operations can be performed correctly. \ No newline at end of file +This ensures arithmetic operations can be performed correctly. + + + +## 2-time-format.js + +### a) How many variable declarations? +There are 6 variable declarations: +- movieLength +- remainingSeconds +- totalMinutes +- remainingMinutes +- totalHours +- result + +--- + +### b) How many function calls? +There is 1 function call: +- console.log(result) + +--- + +### c) What does movieLength % 60 represent? +The % operator returns the remainder after division. +movieLength % 60 gives the number of seconds left after converting full minutes. +In this example, it returns 24 seconds. + +--- + +### d) Interpret line 4 (totalMinutes) +const totalMinutes = (movieLength - remainingSeconds) / 60; + +This subtracts the leftover seconds from the total seconds and divides by 60. +The result is the total number of full minutes in the movie. + +--- + +### e) What does result represent? Better name? +The variable result represents the formatted movie duration in hours:minutes:seconds. +A better name could be: +- formattedTime +- movieDuration +- durationString + +--- + +### f) Will this work for all values of movieLength? +Yes, it works for any positive number of seconds. +However, if movieLength is negative, a decimal, or not a number, the result would be incorrect. +Also, minutes and seconds are not padded with leading zeros, so values like 2:3:5 may appear instead of 02:03:05. \ No newline at end of file From 0b6948d6e7af9b9681b88b5e33dc3e4dd5ec51b3 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 23:02:42 +0000 Subject: [PATCH 14/18] Sprint 1 interpret: complete 3-to-pounds breakdown --- Sprint-1/3-mandatory-interpret/answers.md | 43 ++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/Sprint-1/3-mandatory-interpret/answers.md b/Sprint-1/3-mandatory-interpret/answers.md index 50a94c36db..050a3ee63e 100644 --- a/Sprint-1/3-mandatory-interpret/answers.md +++ b/Sprint-1/3-mandatory-interpret/answers.md @@ -113,4 +113,45 @@ A better name could be: ### f) Will this work for all values of movieLength? Yes, it works for any positive number of seconds. However, if movieLength is negative, a decimal, or not a number, the result would be incorrect. -Also, minutes and seconds are not padded with leading zeros, so values like 2:3:5 may appear instead of 02:03:05. \ No newline at end of file +Also, minutes and seconds are not padded with leading zeros, so values like 2:3:5 may appear instead of 02:03:05. + + + + +## 3-to-pounds.js + +### Step-by-step breakdown (line by line) + +1) `const penceString = "399p";` +- Declares a string containing a price in pence, with a trailing `p` character. + +2) `const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1);` +- Takes a substring from index 0 up to (but not including) the last character. +- Purpose: remove the trailing `"p"`. +- For `"399p"`, this becomes `"399"`. + +3) `const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");` +- Pads the string on the left until it is at least length 3, using `"0"`. +- Purpose: make sure we always have enough digits to represent pounds + pence. +- Example: `"5"` becomes `"005"`, `"50"` becomes `"050"`, `"399"` stays `"399"`. + +4) `const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);` +- Takes everything except the last 2 digits. +- Purpose: the part before the last 2 digits is the pounds. +- For `"399"`, length is 3, so substring(0, 1) → `"3"`. + +5) `const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");` +- First, `substring(length - 2)` takes the last 2 digits. +- Then `padEnd(2, "0")` ensures it’s at least 2 characters (adds zeros on the right if needed). +- Purpose: get exactly two pence digits. +- For `"399"`, last two digits are `"99"` → stays `"99"`. + +6) `console.log(\`£${pounds}.${pence}\`);` +- Uses a template literal to format the final currency string as pounds and pence. +- For pounds `"3"` and pence `"99"` → outputs `£3.99`. + +### Unfamiliar syntax (docs) +- substring: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring +- padStart: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart +- padEnd: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd +- template literals: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals \ No newline at end of file From 1749f57c9ed8a9c5ac4fb8189d9b3e05e0eb4806 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 23:26:06 +0000 Subject: [PATCH 15/18] Sprint 1 stretch: chrome console object exploration --- Sprint-1/4-stretch-explore/answers.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Sprint-1/4-stretch-explore/answers.md diff --git a/Sprint-1/4-stretch-explore/answers.md b/Sprint-1/4-stretch-explore/answers.md new file mode 100644 index 0000000000..38a6bf2bbc --- /dev/null +++ b/Sprint-1/4-stretch-explore/answers.md @@ -0,0 +1,25 @@ +## chrome.md + +### What the task asked me to do +Explore the Chrome DevTools console and investigate what the console object stores and how dot notation works. + +--- + +### What I did (steps) +1. Opened Chrome DevTools and navigated to the Console tab. +2. Entered `console.log` and observed that it returned a function. +3. Entered `console` and observed that it returned an object with multiple methods such as log, warn, error, and assert. +4. Entered `typeof console` and confirmed that console is an object. + +--- + +### What I learned +- `console` stores an object containing many methods used for debugging. +- `console.log`, `console.assert`, etc. are functions stored inside the console object. +- The `.` operator is called dot notation and is used to access properties or methods of an object. + +--- + +### Useful links +- https://developer.mozilla.org/en-US/docs/Web/API/Console +- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects \ No newline at end of file From e8f5887acdc07483f9869d721dc8ef6c74183a70 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 23:31:51 +0000 Subject: [PATCH 16/18] Sprint 1 stretch: object exploration notes --- Sprint-1/4-stretch-explore/answers.md | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Sprint-1/4-stretch-explore/answers.md b/Sprint-1/4-stretch-explore/answers.md index 38a6bf2bbc..ca6d6cfdd6 100644 --- a/Sprint-1/4-stretch-explore/answers.md +++ b/Sprint-1/4-stretch-explore/answers.md @@ -20,6 +20,53 @@ Explore the Chrome DevTools console and investigate what the console object stor --- +### Useful links +- https://developer.mozilla.org/en-US/docs/Web/API/Console +- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects + + + +## objects.md + +### What output did I get? + +- `console.log` → returned a function definition (ƒ log() { [native code] }) +- `console` → returned an object with many methods such as log, warn, error, assert +- `typeof console` → returned "object" + +--- + +### What does `console` store? +The console variable stores an object that contains multiple debugging methods. These methods allow developers to print messages, warnings, errors, and other diagnostic information in the browser console. + +--- + +### What does `console.log` or `console.assert` mean? +These expressions use dot notation to access methods inside the console object. +For example: +- `console.log` accesses the log function +- `console.assert` accesses the assert function + +--- + +### What does the `.` mean? +The dot operator is called dot notation. +It is used to access properties or methods of an object. + +So: +- `console` is the object +- `log` is a method inside that object +- `console.log` means "access the log method from the console object" + +--- + +### What I learned +- Objects store related data and functions together +- The browser console itself is an object +- Dot notation is how we interact with object properties and methods + +--- + ### Useful links - https://developer.mozilla.org/en-US/docs/Web/API/Console - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects \ No newline at end of file From 82a4cf17fcae223cc6da06198bf211d183a91a67 Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Wed, 25 Feb 2026 23:53:48 +0000 Subject: [PATCH 17/18] Sprint 1 interpret: fix percentage-change syntax and tidy notes --- Sprint-1/3-mandatory-interpret/1-percentage-change.js | 3 +-- Sprint-1/3-mandatory-interpret/2-time-format.js | 2 +- Sprint-1/3-mandatory-interpret/answers.md | 2 -- 3 files changed, 2 insertions(+), 5 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..ede0f73e61 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(",", "")); const priceDifference = carPrice - priceAfterOneYear; const percentageChange = (priceDifference / carPrice) * 100; diff --git a/Sprint-1/3-mandatory-interpret/2-time-format.js b/Sprint-1/3-mandatory-interpret/2-time-format.js index 47d2395587..85efdba757 100644 --- a/Sprint-1/3-mandatory-interpret/2-time-format.js +++ b/Sprint-1/3-mandatory-interpret/2-time-format.js @@ -22,4 +22,4 @@ console.log(result); // 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 +// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/answers.md b/Sprint-1/3-mandatory-interpret/answers.md index 050a3ee63e..f0ae4cdafe 100644 --- a/Sprint-1/3-mandatory-interpret/answers.md +++ b/Sprint-1/3-mandatory-interpret/answers.md @@ -120,8 +120,6 @@ Also, minutes and seconds are not padded with leading zeros, so values like 2:3: ## 3-to-pounds.js -### Step-by-step breakdown (line by line) - 1) `const penceString = "399p";` - Declares a string containing a price in pence, with a trailing `p` character. From bb9e9015acf6da23507be81797abccee19ef035b Mon Sep 17 00:00:00 2001 From: Richard Frimpong Date: Fri, 13 Mar 2026 01:19:59 +0000 Subject: [PATCH 18/18] Address mentor feedback: clarify increment operation and explain padEnd is unnecessary --- Sprint-1/1-key-exercises/1-count.js | 11 +++++------ Sprint-1/3-mandatory-interpret/answers.md | 9 +++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Sprint-1/1-key-exercises/1-count.js b/Sprint-1/1-key-exercises/1-count.js index ea3bba9473..b87b95a4f5 100644 --- a/Sprint-1/1-key-exercises/1-count.js +++ b/Sprint-1/1-key-exercises/1-count.js @@ -1,11 +1,10 @@ +// This script shows how a counter changes step by step. + let count = 0; +// Line 3 increments the current value of count by 1. +// It takes the current value of count (0), adds 1 to it, +// and assigns the result (1) back to the count variable. count = count + 1; console.log(count); - -// Line 1 is a variable declaration, creating the count variable with an initial value of 0 -// Describe what line 3 is doing, in particular focus on what = is doing - -// Line 3 takes the current value of count (0), adds 1 to it, -// and assigns the result (1) back to the count variable using =. \ No newline at end of file diff --git a/Sprint-1/3-mandatory-interpret/answers.md b/Sprint-1/3-mandatory-interpret/answers.md index f0ae4cdafe..25b00d0c26 100644 --- a/Sprint-1/3-mandatory-interpret/answers.md +++ b/Sprint-1/3-mandatory-interpret/answers.md @@ -139,10 +139,11 @@ Also, minutes and seconds are not padded with leading zeros, so values like 2:3: - For `"399"`, length is 3, so substring(0, 1) → `"3"`. 5) `const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");` -- First, `substring(length - 2)` takes the last 2 digits. -- Then `padEnd(2, "0")` ensures it’s at least 2 characters (adds zeros on the right if needed). -- Purpose: get exactly two pence digits. -- For `"399"`, last two digits are `"99"` → stays `"99"`. +- First, `substring(paddedPenceNumberString.length - 2)` takes the last 2 characters. +- Because `paddedPenceNumberString` has already been padded earlier with `padStart(3, "0")`, it will always be at least 3 characters long. +- That means the substring operation already returns exactly 2 characters for any valid `penceString`. +- So `.padEnd(2, "0")` is not actually needed in this script. +- For `"399"`, the last two digits are `"99"`, so the result stays `"99"`. 6) `console.log(\`£${pounds}.${pence}\`);` - Uses a template literal to format the final currency string as pounds and pence.