Skip to content

Conversation

@ahmadehsas
Copy link

@ahmadehsas ahmadehsas commented Aug 9, 2025

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 Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist:

Completed all the mandatory tasks.

Questions

Ask any questions you have for your reviewer.

@ahmadehsas ahmadehsas added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 9, 2025
@LonMcGregor LonMcGregor added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. 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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 11, 2025
@LonMcGregor
Copy link

It looks like there are a lot of files included here - from multiple sprints. Can I just confirm which ones you wanted reviewed?

@ahmadehsas
Copy link
Author

ahmadehsas commented Aug 11, 2025 via email

@LonMcGregor LonMcGregor added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 12, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Hi, I've reviewed sprint 2 now. If the sprint 1 files are not meant to be there, can you remove them from the pull request please? Also, can you fix the package-lock.json file - if you didn't intentionally change that file, it should not have any changes comitted.

For sprint 2, you have made a good start, but I have some follow up questions for you to answer

// This means that we need to check if the property belongs to the object using hasownproperty whenever we loop through an object with the `for ... in` loop.

for (const key in author) {
if (author.hasOwnProperty(key)) {

Choose a reason for hiding this comment

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

What are you using hasOwnProperty to do here?

Copy link
Author

Choose a reason for hiding this comment

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

The Sprints 1, 2 and 3 files are in the same folder, and my Sprint-1 has already been reviewed. Is it necessary to remove it?

Copy link
Author

Choose a reason for hiding this comment

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

hasOwnproperty is being used to check whether the key belongs directly to the author object itself, not to something it inherited from its prototype chain.

Choose a reason for hiding this comment

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

Thanks for answering about hasownproperty. For the files in the other sprints, if they are not relevant to this pull request, they should be removed from the branch.

(hint: the files should be restored to original state note deleted entirely)

${recipe}`);
// Here we add `join("\n") to the ingredients array to log each ingredient in a new line.
console.log(
`${recipe.title} serves ${

Choose a reason for hiding this comment

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

Is there a reason you wrote the recipe.serves variable over multiple lines?

Copy link
Author

Choose a reason for hiding this comment

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

Breaking recipes into multiple lines just makes the final string output easier to read when you look at the code.

Choose a reason for hiding this comment

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

I meant the code itself on line 16 - is there a reason you wrote the variable recipe.serves in the template expression over multiple lines instead of one line?

Copy link
Author

Choose a reason for hiding this comment

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

I think there is no functional reason for splitting recipe. serves over multiple lines. If we write in one line or multiple lines, it doesn't change the output.

// When passed to contains
// Then it should return false or throw an error
test("contains on an array returns false", () => {
expect(contains([1, 2, 3], 4)).toBe(false);

Choose a reason for hiding this comment

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

What happens if you test for something like contains([1,2,3,4], "length")?

Copy link
Author

Choose a reason for hiding this comment

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

The test returns true because 'length' is a property of the array object

// it needed because it converts the object into an array of [key, value] pairs which makes it easy to loop over both key and value at the same time.

// d) Explain why the current return value is different from the target output
// because it returns the [key, value] of an object in reverse order [value,key]

Choose a reason for hiding this comment

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

I think this question was asking why the original output of this program was not what was expected (before you fixed it) - can you explain why you made the change you did and what the mistake was?

Copy link
Author

Choose a reason for hiding this comment

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

Because it was required to fix the implementation and write tests to prove it is fixed. I followed the instructions and made the required changes. There were a lot of mistakes at first when I wanted to check the test, and there were errors.

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 12, 2025
@ahmadehsas ahmadehsas added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 13, 2025
@LonMcGregor
Copy link

Thanks for answering my questions. To review what still needs to be addressed here:

  • Can you please revert the changes from sprint 1 so this branch and PR only has sprint 2's files?
  • You are correct about recipe.serves not making a difference functionally, but it would be easier to read the code if it was all on one line. Can you fix this?
  • Can you address my most recent comment about making contains give a false or error response when given array as input?

@LonMcGregor LonMcGregor removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 13, 2025
@LonMcGregor LonMcGregor added the Reviewed Volunteer to add when completing a review with trainee action still to take. label Aug 13, 2025
@ahmadehsas ahmadehsas added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 15, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (SPRINT-2) doesn't match expected format (example: 'Sprint 2', without quotes)

1 similar comment
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (SPRINT-2) doesn't match expected format (example: 'Sprint 2', without quotes)

@ahmadehsas ahmadehsas changed the title WESTMIDLANDS | ITP-MAY-25 | AHMADEHSAS | SPRINT-2 | DATA GROUPS WESTMIDLANDS | ITP-MAY-25 | AHMADEHSAS | SPRINT-2 | DATA GROUPS Aug 15, 2025
@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Sprint part (SPRINT-2 ) doesn't match expected format (example: 'Sprint 2', without quotes)

@ahmadehsas ahmadehsas changed the title WESTMIDLANDS | ITP-MAY-25 | AHMADEHSAS | SPRINT-2 | DATA GROUPS WESTMIDLANDS | ITP-MAY-25 | Ahmad Ehsas | Sprint 2| DATA GROUPS Aug 15, 2025
@LonMcGregor
Copy link

Hi,

  • This PR still has all your Sprint 1 files (the PR is titled Sprint 2, so should only have those files). You can see these if you visit the "Files Changed" tab on this page. If you were reviewing someone else's code and there were lots of unrelated files, can you see why that might be a problem?
  • When discussing the code being on one line, we were looking at recipe.js. If you imagine reading this file as someone else, can you see how having variables in templates over multiple lines might make it more difficult to read? What could you do to make this easier to read for someone who did not write this code?
  • For contains.test.js You have now got a more correct test - what happens when you run this test?

@LonMcGregor LonMcGregor 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 Aug 18, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants