Skip to content

ITP Jan 25 | Katarzyna Kazimierczuk | Data Flows | Sprint 1 #211

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

katarzynakaz
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@katarzynakaz katarzynakaz added the Needs Review Participant to add when requesting review label Apr 21, 2025
@katarzynakaz katarzynakaz requested a review from shieldo April 21, 2025 17:46
@katarzynakaz katarzynakaz changed the title ITP JAn 25 | Katarzyna Kazimierczuk | Data Flows | Sprint 1 ITP Jan 25 | Katarzyna Kazimierczuk | Data Flows | Sprint 1 Apr 21, 2025
@katarzynakaz katarzynakaz requested review from shieldo and removed request for shieldo April 21, 2025 18:04
Copy link

@shieldo shieldo left a comment

Choose a reason for hiding this comment

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

Generally it does look like you've understood destructuring well. There may be an issue in the first exercise when using it with function syntax - I would recommend running the exercise.js scripts to check your work. Good work generally though!

@@ -6,7 +6,7 @@ const personOne = {

// Update the parameter to this function to make it work.
// Don't change anything else.
function introduceYourself(___________________________) {
function introduceYourself(name, age, favouriteFood) {
Copy link

Choose a reason for hiding this comment

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

When this script is now run, what happens?

There are three different parameters defined here in the function - the place where the function is called only passes in one argument, which is the personOne object. This contains fields that happen to be called name, age, and favoriteFood. Restructuring gives us a way to pass a whole object into a function, but for the function to pick out only the fields it needs, and to access them in a simple way (i.e. as name and age etc, rather than person.name and person.age which can get needlessly repetitive).

I would have a look at this section of the MDN documentation for destructuring in JavaScript, which gives some relevant examples - notice the brace ({ and }) characters inside the parentheses in the function definition. This kind of syntax is subtle, and a bit magical, but hopefully at some point it will click for you. It's definitely commonly used in JavaScript and TypeScript these days.

Copy link
Author

Choose a reason for hiding this comment

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

of course, it should be ({name, age, favouriteFood}), with the current one will get undefined.

favouriteFood: "Spinach",
};

let personOne { name, age, favouriteFood } = personOne
Copy link

Choose a reason for hiding this comment

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

Close, but this doesn't need the initial personOne. We're using let to declare three variables (name, age, and favouriteFood) which are mapped from the fields with those names when the object personOne on the right hand side of the assignment operator (=) is destructured, i.e. taken apart into its constituent parts.

Copy link
Author

Choose a reason for hiding this comment

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

It absolutely does not! It's now corrected.

})

return teachersWithPets;
}
Copy link

Choose a reason for hiding this comment

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

When I add the lines:

console.log(sortingHat(hogwarts));
console.log(findTeachersWithPets(hogwarts));

I do get the expected output when running the file. You've used destructuring effectively here to pick out from objects only the specific fields that you need. Good stuff!


createReceipt(order);

//I have the receipt in a table format it is not identical to the one in the example but it is a table format :)
Copy link

Choose a reason for hiding this comment

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

It certainly is a table format :)

Usually when we have an expected format we want to follow that format - but you've done the destructuring part here fine and all the numbers are correct, so this is fine :)

@shieldo shieldo added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Apr 21, 2025
@katarzynakaz katarzynakaz added the Complete Volunteer to add when work is complete and review comments have been addressed label Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complete Volunteer to add when work is complete and review comments have been addressed Reviewed Volunteer to add when completing a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants