Skip to content

London | 26-ITP-SEPT | Carol Nassuna | Sprint 2 | Coursework - #1577

Open
Mugs3 wants to merge 3 commits into
CodeYourFuture:mainfrom
Mugs3:coursework/sprint-2
Open

Mugs3 wants to merge 3 commits into
CodeYourFuture:mainfrom
Mugs3:coursework/sprint-2

Conversation

@Mugs3

@Mugs3 Mugs3 commented Sep 22, 2026 •

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1039

Changelist

24/09 - Updated files as per review instructions
24/09 - Corrected issues raised by the reviewer
I have updated and committed files in Sprint 2 - Key exercises, mandatory errors and mandatory interpret folders

@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cyf-onboarding-module ready!

Name Link
🔨 Latest commit b6395cf
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6ab579b575377700085ea0c9
😎 Deploy Preview https://deploy-preview-1577--cyf-onboarding-module.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
2 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 86 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@Mugs3 Mugs3 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 22, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your 2-mandatory-errors answers are clear: each one has node's error message and a reason. 2.js and 4.js also run now. 3-paths.js works for any file name too, because you used lastIndexOf.

I have left a hint on each line. Before I can mark this Complete:

  1. 1.js and 3.js still stop with an error. Your notes say you fixed them, but the code has not changed.
  2. 4-random.js: say what num is, and explain each part of line 4.
  3. 1-percentage-change.js: answer a), and the line number in b).
  4. 2-time-format.js: answers b), c) and d), and a better name in e).
  5. 3-to-pounds.js: steps 2 and 5.
  6. 2-initials.js lines 4 to 7: delete the old code you commented out. Git keeps the old version for you.
  7. Prettier again: most of your files fail. Open each file you changed, right click, and choose Format Document. To make this happen every time you save, follow the format on save steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md

Add the Needs Review label again once you have pushed.

Comment thread Sprint-2/2-mandatory-errors/1.js Outdated
console.log(age)

// The TypeError: Assignment to constant variable implies we are trying to reassign the variable twice.
// This case, I have used let instead in order to allow the variable to be reused. No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your explanation is right. But line 3 still says const, so the file still stops with the same TypeError. Did you forget to save or commit the change? Run node 1.js to check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The file runs now.

Comment thread Sprint-2/2-mandatory-errors/3.js Outdated
//Prediction was the code would run successfully without error although with the wrong results due to absence of syntax errors in the file
// Error returned: TypeError: cardNumber.slice is not a function
// Lesson learnt here; slice method is only available for strings or arrays not numbers
// So converted the cardNumber into a string first No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your notes are right, and it is good that you wrote down your prediction. But line 2 has not changed. So the file still gives TypeError: cardNumber.slice is not a function.

How can line 2 turn cardNumber into a string before .slice? String(...) turns a value into a string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed line 1 into a string. But the exercise asks you to change line 2, the expression last4Digits is assigned to. The number on line 1 stays a number, and line 2 turns it into a string.

Please change lines 1 and 2 to this:

const cardNumber = 4533787178994213;
const last4Digits = String(cardNumber).slice(-4);

Then update your note on line 15. Say that you used String() on line 2 to turn the number into a string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The file prints 4213 now.

Comment thread Sprint-2/1-key-exercises/4-random.js Outdated

// Answer: For calculations i utilised BODMAS formula solving numbers in brackets first, multiplication, subtraction and addition
// I used 0.68 for math.floor(random number) + 1
// Sum = 69 No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your example is a good start: 0.68 gives 69. Now say what num is in general. Log num and run the file a few times. What is the smallest value it can be? And the largest?

Also explain each part of line 4. Math.random() gives a decimal from 0 up to 1, but never 1. What does * 100 do to it? Then what does Math.floor do? And + minimum?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps 2 to 4 are right. Two small things are missing: the largest value of num, and what + minimum does.

Please change step 1, and add a step 5, like this:

// 1. num is a random whole number from 1 to 100.
// 5. + minimum adds 1. So the range 0 to 99 becomes 1 to 100.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


// a) How many function calls are there in this file? Write down all the lines where a function call is made

// 2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Count again. A function call is a name followed by (...). Line 4 has two: Number(...) and .replaceAll(...). Line 5 has two as well. And what is console.log(...) on line 10?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 is right, and you are very close. Just fix two line numbers:

  • Line 17: the second Number() and .replaceAll() are on line 5, not line 4.
  • Line 18: console.log() is on line 10. Please add "in line 10".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Both line numbers are right now.

//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ","));
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?

//b) error = SyntaxError: missing ) after argument list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is right, and your fix works. Which line was the error on? Write the line number too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Line 5 is right.

// 2
// c) Using documentation, explain what the expression movieLength % 60 represents
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
// It means 60 % remainder of Movie length

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

% gives the remainder after a division. So movieLength % 60 is what is left after taking out the whole minutes. It gives 24. Are those 24 seconds, minutes or hours?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24 seconds is right. Please delete the old answer above it: // It means 60 % remainder of Movie length.

// It means 60 % remainder of Movie length

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
// totalMinutes is assigned a value of the result from (movieLength - remainingSeconds) / 60;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repeats the code. What does it mean? First, movieLength - remainingSeconds takes away the 24 leftover seconds. Then it divides by 60. What does the result count?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Taking away the 24 seconds first means the division by 60 gives a whole number.

// totalMinutes is assigned a value of the result from (movieLength - remainingSeconds) / 60;

// e) What do you think the variable result represents? Can you think of a better name for this variable?
// I think its the total movie length with a timer. Based on research it appears to be template literal variable as it mixes static text with dynamic data. Sorry I don't fully understand this bit yet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, it is the movie length. It is shown as hours:minutes:seconds, for example 2:26:24. Now suggest a better name for result. Which name would tell a reader what it holds?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good name. One small thing: variable names start with a small letter, so movieDuration.


// To begin, we can start with
// 1. const penceString = "399p": initialises a string variable with the value "399p"
// 2. const penceStringWithoutTrailingP = penceString.substring(0): sets penceStringWithoutTRailingP = 399.0 - penceString -1 = 39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

substring(0, penceString.length - 1) keeps every character except the last one. So from "399p", what is left? Log penceStringWithoutTrailingP to check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the p is dropped. Please delete the old step 2 above it, the line that ends with = 39.

// 2. const penceStringWithoutTrailingP = penceString.substring(0): sets penceStringWithoutTRailingP = 399.0 - penceString -1 = 39
// 3. const paddedPenceNumberString - ensures the figure is 3 characters to taking us back to 399
// 4 const pounds - removes 2 characters from the amount = 3
// 5. const pence - adds the amount by 2 characters taking us back to either 39 or 99

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

substring(paddedPenceNumberString.length - 2) takes the last two characters. From "399", which two are they? padEnd(2, "0") only adds zeros when the string is shorter than 2.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"99" is right. But padEnd does not add anything here. Here is why:

  • substring(paddedPenceNumberString.length - 2) takes the last two characters of "399". That gives "99".
  • padEnd(2, "0") adds zeros only when the string is shorter than 2 characters. "99" already has 2 characters, so nothing is added.

Please update your step 5 to say this in your own words. Also delete the old step 5 above it, the line that starts // 5. const pence - adds the amount by 2 characters.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@abdishakoor-dev abdishakoor-dev added Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 23, 2026
@Mugs3 Mugs3 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 24, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You fixed a lot this time, thanks. 1.js runs now, and your answers to b), c) and e) in 2-time-format.js are right.

You are very close. I want you to finish this and move on to the next sprint. So in each reply below, I have written exactly what to change. Please read each reply, make the change, and then push.

Here is the list:

  1. 3.js: lines 1 and 2. My reply has the two lines to use.

  2. 4-random.js: change step 1 and add a step 5. My reply has the text.

  3. 1-percentage-change.js a): two line numbers.

  4. 3-to-pounds.js step 5: what padEnd does here.

  5. Delete three old answers. When you update an answer, you can delete the old one. Git keeps the old version for you. Delete these lines:

    • 2-time-format.js: // It means 60 % remainder of Movie length
    • 3-to-pounds.js: the old step 2, which ends with = 39
    • 3-to-pounds.js: the old step 5, which starts // 5. const pence - adds the amount by 2 characters
  6. Prettier. Six files are not formatted yet: 1-count.js, 2-initials.js, 3-paths.js, 4-random.js, 0.js and 2.js. For each file:

    1. Open the file in VS Code.
    2. Right click anywhere in the code.
    3. Choose Format Document. If VS Code asks which formatter to use, choose Prettier.
    4. Save the file with Ctrl + S.

    When all six are done, commit and push. To make VS Code do this every time you save, follow the format on save steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md

Add the Needs Review label again once you have pushed.

@abdishakoor-dev abdishakoor-dev added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 24, 2026
@Mugs3 Mugs3 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 24, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You made every change on the list. All your files run, and Prettier passes on all of them.

Well done for sticking with this. Marking this Complete.

@abdishakoor-dev abdishakoor-dev added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants