-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
NW-6 | AREEB-SATTAR | JS3| [TECH ED] Array Destructuring | WEEK-3 #306
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
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 is great work on destructuring in lambda functions, Areeb! I'm just going to put this ticket back on the backlog to make sure you've got the hang of exercise 1.
It needs us to use destructuring inside the function's parameters, so it will on the same line as the function declaration itself. Look out for some examples under "Unpacking properties from objects passed as a function parameter" on this MDN Web Doc
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.
Great use of destructuring, Areeb!
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.
There's two files from the book-library/
directory that have sneaked their way into this PR. A good habit is to make sure you're on the correct branch when you commit 🙂
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.
I did realize this later, I will try to be more careful with this in future
|
||
let sum = 0; | ||
|
||
order.forEach(({ itemName, quantity, unitPrice }) => { |
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.
Excellent!
I have made some changes to excercise-1 again. I hope this time it is how it's supposed to be |
function introduceYourself(___________________________) { | ||
let { name, age, favouriteFood } = personOne; | ||
|
||
function introduceYourself(personOne) { |
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.
I think this would be a good time to introduce a new way to use destructuring. This function takes a parameter that is an object. We know the object will be a person that has a name, age, and favourite food.
Because we know exactly what information we need from the object, we can destructure it right here as we define the function.
function introduceYourself({ name, age, favouriteFood })
will give us the name
, age
, and favouriteFood
to use inside of the function block.
Every time we pass a person object to the function, the code will now magically extract those properties from the object without us doing any extra work! 🚀
Let me know if that makes sense @areebsattar
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.
Thank you for this explanation, it does make it clearer and I believe what we were doing with props in React also made it clearer as well.
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.