Skip to content

London | 26-ITP-Sep | Anita Amirhaeri | Sprint 2 | Coursework/sprint 2 - #1553

Open
anitahy73 wants to merge 20 commits into
CodeYourFuture:mainfrom
anitahy73:coursework/sprint-2
Open

anitahy73 wants to merge 20 commits into
CodeYourFuture:mainfrom
anitahy73:coursework/sprint-2

Conversation

@anitahy73

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

Sprint 2 | Coursework/sprint 2

Questions

Added comments to explain variable declaration and assignment.
Updated the initials variable to dynamically generate initials from first, middle, and last names.
Corrected comments to clarify the purpose of line 3.
Added variables to extract directory and extension from filePath.
Updated comments to clarify the purpose of the random number generation and the evaluation order of expressions.
Changed 'const' to 'let' for age variable and reassigned it to 1.
Fix variable declaration order to enable correct logging.
Updated last4Digits assignment to convert cardNumber to a string before slicing.
Updated comments to provide answers to questions about the code.
Added comments to explain the purpose of each line in the program.
Clarified effects and return values of alert and prompt functions.
@netlify

netlify Bot commented Sep 20, 2026

Copy link
Copy Markdown

Deploy Preview for cyf-onboarding-module ready!

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

@anitahy73 anitahy73 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Onboarding The name of the module. labels Sep 20, 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.

Good start. initials and dir both come out right, and your answer to e) in 1-percentage-change.js is clear.

Some things to fix before I can mark it Complete:

  1. 2-mandatory-errors/3.js still stops with an error. See my comment on line 2.

  2. 2-mandatory-errors/1.js line 4 changes what the program does. See my comment.

  3. 2-mandatory-errors/1.js, 2.js, 3.js and 4.js: the code is fixed, but no error is written down. The README asks you to explain each error. See my comment on 2.js.

  4. 1-key-exercises/4-random.js: one step is missing from your breakdown.

  5. 3-mandatory-interpret/1-percentage-change.js: answers a) and b) need a little more.

  6. 3-mandatory-interpret/2-time-format.js: answers c), d) and e) are only half done.

  7. 3-mandatory-interpret/3-to-pounds.js: the breakdown stops at line 9. Lines 9 to 18 have no explanation yet.

  8. "My code is consistently formatted" is on the checklist. The tool that does it is called Prettier. It sets spacing and indentation to one agreed style. Then a reviewer sees only the changes you meant to make. Right now nine of your files fail that check.

    Prettier comes with the CYF extension pack from onboarding. If you are not sure you have it, open VS Code, go to Extensions, and search for CodeYourFuture Extension Pack: https://marketplace.visualstudio.com/items?itemName=CodeYourFuture.cyf-extension-pack

    Then open each file you changed, right click in the editor, and choose Format Document. Pick Prettier if VS Code asks. Save, commit and push. To do this on every save, follow the steps here: https://github.com/CodeYourFuture/Module-JavaScript-Fundamentals/blob/main/practical_guide.md

Add the Needs Review label again once you have pushed and I will take another look.

Comment thread Sprint-2/2-mandatory-errors/3.js Outdated
const cardNumber = 4533787178994213;
const last4Digits = cardNumber.slice(-4);

const last4Digits = string(cardNumber).slice(-4);

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 node 3.js. It stops with a new error. Look at the capital letters. Is string the same as String?

Comment thread Sprint-2/2-mandatory-errors/1.js Outdated
const age = 33;
age = age + 1;
let age = 33;
age = 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.

Line 1 says the goal. The age should go up by 1. With this line, what is age after line 4? Is that 34?

Comment thread Sprint-2/2-mandatory-errors/2.js Outdated
@@ -1,5 +1,5 @@
// Currently trying to print the string "I was born in Bolton" but it isn't working...
// what's the error ?
// what's the error

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 fix works. But the question "what's the error?" has no answer yet. Put the original code back for a moment. Run it, and copy the exact message node prints. Then explain in your own words why it happens. Do the same in 1.js, 3.js and 4.js. In 3.js, also say if your prediction was right.

// In this exercise, you will need to work out what num represents?It gives us a random number between 1-100
// Try breaking down the expression and using documentation to explain what it means
//Math.random gives us a random number between 0-1 and the next parantecec returns 100
//after that we multiple these two given values between 0-100 and the floor methode rounds down the given value

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.

After Math.floor, the number is from 0 to 99. What does + minimum do next? What is the smallest num can be, and the biggest?

//Line 5
//Number(...)
//Line 5
//console.log

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 count of 5 is right. Which line is console.log on?


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

//missing a comma between the two arguments.

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 reason is right. The question also asks which line. And what error name did node print?

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

// c) Using documentation, explain what the expression movieLength % 60 represents
//The % operator is called the remainder operator.

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 explains % in general. What does movieLength % 60 mean in this program? It is 24 here. 24 what?

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?This removes the seconds that don't make up a complete minute.

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.

That is the first half. What does dividing by 60 give you after that?

// d) Interpret line 4, what does the expression assigned to totalMinutes mean?This removes the seconds that don't make up a complete minute.

// e) What do you think the variable result represents? Can you think of a better name for this variable?
// e) What do you think the variable result represents? Can you think of a better name for this variable?creates a formatted representation of the movie's length in hours, minutes, and seconds.

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 question also asks for a better name. What would you call it?

//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");This uses padStart() to make sure the string has at least 3 characters.
//const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
//This line extracts the pounds part.

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 27 and line 28 repeat the same code. Keep one. Then keep going. What do lines 14 to 16 give for pence? What does padEnd do there? And what does line 18 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 21, 2026
Corrected the type conversion from 'string' to 'String' for proper functionality.
Fixed comment to clarify the error message.
Updated comments to clarify the random number generation process.
Updated comments to clarify error details and variable reassignment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Onboarding The name of the module. 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