Skip to content

London | 26-ITP-Sep | Diana Ausiejute | Sprint 2 | JavaScript Fundamentals - #1571

Open
ausiejute wants to merge 17 commits into
CodeYourFuture:mainfrom
ausiejute:coursework-sprint-2-clean
Open

ausiejute wants to merge 17 commits into
CodeYourFuture:mainfrom
ausiejute:coursework-sprint-2-clean

Conversation

@ausiejute

@ausiejute ausiejute 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

This branch was recreated from main so that it contains only Sprint-2 coursework.

Fixed everything that was pointed out.

@netlify

netlify Bot commented Sep 22, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module ready!

Name Link
🔨 Latest commit f1cf999
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6ab3fd9ec16538000970c289
😎 Deploy Preview https://deploy-preview-1571--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.

@ausiejute ausiejute added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 2 Assigned during Sprint 2 of this module labels Sep 22, 2026
@ausiejute ausiejute changed the title London| 26-ITP-Sep | Diana Ausiejute | Sprint 2 | Coursework - Sprint 2 London | 26-ITP-Sep | Diana Ausiejute | Sprint 2 | JavaScript Fundamentals 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 answers in 1.js, 2.js and 4.js are clear. Each one has node's message, the reason, and a fix that runs. Prettier passes on every file, too.

Some answers need another look before I can mark this Complete:

  1. 1-key-exercises/3-paths.js line 31: check dir against the diagram.
  2. 1-key-exercises/4-random.js: break the expression down, step by step.
  3. 2-mandatory-errors/3.js: the fix changes the wrong line.
  4. 3-mandatory-interpret/1-percentage-change.js: answers a), b) and d).
  5. 3-mandatory-interpret/2-time-format.js: answers b), d), e) and f).
  6. 3-mandatory-interpret/3-to-pounds.js: lines 29 to 35 say some values are numbers. There is also no step for line 18.
  7. Delete the old code you commented out. Git keeps the old version for you. That is 3-paths.js lines 24 to 30, 1.js lines 3 and 4, 2.js lines 4 and 5, 3.js line 2 and 4.js lines 1 and 2. Also delete the second console.log(result); on line 29 of 2-time-format.js.

See my comment on each line. Add the Needs Review label again once you have pushed.

Comment thread Sprint-2/1-key-exercises/3-paths.js Outdated
//const dir = filePath.slice(0 + lastSlashIndex);
//const dir = filePath.slice(0 + (lastSlashIndex - 1));
//const dir = filePath.slice(0 + (lastSlashIndex - 44));
const dir = filePath.slice(0, lastSlashIndex + 1);

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.

Log dir and compare it with the diagram. Your dir ends with a /. Is that last / part of dir? Or is it the separator between dir and base?

@ausiejute ausiejute Sep 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The last trailing slash is part of dir, because from what I've found, directory path variables should end with a trailing slash to clearly indicate that they represent directories. Edit. I see, for Unix it's different. Will fix it.

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, thanks.

// 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);
// This expression uses a function that returns a random number between (min)1 and (max)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.

The range is right. The exercise also asks you to break the expression down. What does Math.random() give? What does Math.floor do to it? Which part makes the smallest value 1?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Math.random() gives a decimal between 0 < 1. I multiply it by 100 to stretch it out, then Math.floor() chops off the decimals to make it a whole number. That gives me 0 to 99. The minimum at the end just adds 1 to the whole thing, so now it goes from 1 to 100 instead of 0 to 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.

Clear now, thanks.

// The actual error indicates that on the 3rd line there is a typeError: "cardNumber.slice is not a function"
// Checked the error reference and decided to look more closely. Noticed that the card number is used as a number,
// so it answers why the function couldn't be called - because they can be only called on Arrays and Strings.
// Therefore, I'll add parentheses to turn the card number into a string (so that the function could be called)

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 of the error is good. But look at line 1. You changed cardNumber itself into a string. The exercise asks you to change the expression on line 3 instead. How can line 3 turn the number into a string?

@ausiejute ausiejute Sep 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Interesting. And yes, I need to focus more on what the exercise asks me to do. Fixed it by converting the number into string programmatically and then used the same method to extract the last 4 numbers

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 fix on line 2 is right now.


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

// 4, 5, 8

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.

Look at line 8 again. Is anything called there? And look at line 10. What is console.log(...)? Also, how many calls are there in total? Line 4 has two.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

5 in total?

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.

Yes, five. Your answer is right now.

Your debugging line 6, console.log(carPrice), is a function call too. It makes the count six. But I am ignoring it, because I think you forgot to remove it.

// 4, 5, 8
// 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?

// It was a syntax error, it can be fixed by adding the missing part (1 of 2 parentheses)

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.

Node says "missing ) after argument list", but a bracket was not the problem. Compare line 5 with line 4 in the original. What was missing between the two arguments? And which line was it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

not sure

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 problem is on line 5 of the original code: replaceAll("," ""). This has two arguments, "," and "". What always goes between two arguments? Look at line 4, where it is there.

Node says a ) is missing, but that is only node's guess. So in b), write the line number and the character that is really missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh, it was a comma between two arguments in line 5.

// 6
// b) How many function calls are there?

// 5

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.

Which five? % and / are operators, not function calls. Look for a name followed by (...).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh I see. So only the console.log(result) then

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.

Yes, only one. Your new answer is right.


// d) Interpret line 4, what does the expression assigned to totalMinutes mean?

// total minutes (in seconds) - remaining seconds = remaining seconds. Then converts the seconds into minutes

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.

Line 4 starts with movieLength, not total minutes. What is 8784 - 24? Why does the program take the 24 seconds away before it divides by 60?

@ausiejute ausiejute Sep 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  1. It's movieLength - remainingSeconds. Because those seconds don't form a complete minute, so it's better to remove them in order to avoid a messy decimal

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 new answer on lines 23 and 24 is right.

// total minutes (in seconds) - remaining seconds = remaining seconds. Then converts the seconds into minutes
// e) What do you think the variable result represents? Can you think of a better name for this variable?

// It represents how much of the movie is left to watch. Maybe something like remainderOfTheMovie

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.

Run the file. It prints 2:26:24. movieLength is the length of the whole movie. So is result the time left to watch?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

oh, i see, so the result could be replaced into something like totalMovieLength

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.

Yes. It is the whole movie length, shown as hours:minutes:seconds. Your new answer on line 27 is right.


// It represents how much of the movie is left to watch. Maybe something like remainderOfTheMovie
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
// It won't work with all values. Most importantly, the value must be strictly numeric and positive

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.

Try some values and write down what each one prints. Try 59, -90 and 90.5. Would you show a time that way?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

0:0:59 , 0:-1:-30 , 0:1:30.5. Definitely not. I obviously haven't checked the edge cases

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.

Those three results are right. Please write them in answer f) in the file. Add one short reason for each. For example, 59 gives 0:0:59, but a clock shows 00:00:59. What is wrong with the -90 result? And with 90.5?

Then delete "and not messy ()" on line 29. It is not clear.

// 3-6. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1);
// : initializes a variable, the value of which is turned to numerical by removing the letter "p".
// 8. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
// Here the padstart function turns "399" string into 399 number (it could add some zeroes in front, but here it serves as a converter)

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.

Does padStart turn "399" into a number? Change line 1 to "5p" and run it. What does each line give now? That shows what padStart and padEnd are for.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Interesting

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 new line 32 is right.

Line 29 says the value becomes a number. But substring always gives back a string. So "399" is still a string. Write that on line 29.

There is still no step for line 18. Line 18 uses a template literal. What does it join together, and what does it print?

@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 22, 2026
@ausiejute ausiejute added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 23, 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 since my last review, thanks. dir in 3-paths.js is right now. Your 4-random.js breakdown is clear, and the 3.js fix is right.

You are close. I have left a strong hint on each line below. These are the last things:

  1. 1-percentage-change.js: answers b), c) and d).
  2. 2-time-format.js: add your test results to f).
  3. 3-to-pounds.js: fix line 29. Add a step for line 18.
  4. When you update an answer, you can delete the old one. You don't need to keep a history of your changes in the file. Git keeps that for you. Please delete these old answers:
    • 2-time-format.js lines 17 (the old 5), 22 and 26
    • 3-to-pounds.js line 31
  5. The same goes for old code. Please delete the code you commented out: 3-paths.js lines 24 to 30, 1.js lines 3 and 4, 2.js lines 4 and 5, and 4.js lines 1 and 2.
  6. Four files fail Prettier now: 4-random.js, 3.js, 1-percentage-change.js and 2-time-format.js. Open each one, 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.

@abdishakoor-dev abdishakoor-dev removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants