-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
West Midlands | Danial Bashirzadeh | Module-Data-Flows | sprint1 | Destructuring #133
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, good job!
|
||
const itemTotal = quantity * unitPricePence; | ||
total += itemTotal; | ||
console.log(`${quantity.toString().padEnd(8)}${itemName.padEnd(20)}${(itemTotal/100).toFixed(2)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you changed one of these numbers (e.g. made itemName
pad to 25 instead of 20), you'd have to change another line of code a well.
Can you think how you can make it so that if you changed one of these numbers, you wouldn't need t ochange anything else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Daniel for the valuable feedback. You are right, I can use a constant or variable to define the padding values, instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're currently only using the values 8 and 20 in one place, so I don't think a constant or variable would help here? That would only help if you were writing down 8 and 20 in multiple places...
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.