Skip to content

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

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

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

Conversation

@ausiejute

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.

@netlify

netlify Bot commented Sep 22, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module ready!

Name Link
🔨 Latest commit 5b83030
🔍 Latest deploy log https://app.netlify.com/projects/cyf-onboarding-module/deploys/6ab266546b5e5b000884a969
😎 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.

// 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

// 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?


// 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.

// 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?

// 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 (...).


// 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?

// 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?


// 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?

// 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.

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