Skip to content

Zebra#1924

Open
sanchez-primal wants to merge 2 commits intomate-academy:masterfrom
sanchez-primal:develop
Open

Zebra#1924
sanchez-primal wants to merge 2 commits intomate-academy:masterfrom
sanchez-primal:develop

Conversation

@sanchez-primal
Copy link

Is this really optimal? Why not use that querySelectorAll inside a list, apart from other things?

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job on implementing the DOM sorting logic! The list is correctly reordered on the page. However, this submission requires changes because a key requirement for the getEmployees function has not been met. According to the task, this function must return an array of JavaScript objects, each matching the schema { name, position, salary, age }. Your current implementation returns an array of DOM elements instead. Please adjust the function to map over the list items, extract the data from their dataset attributes, and construct an object for each employee.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 18 to 20
return [...list.childNodes].filter(
(el) => el.nodeType === 1 && el.dataset.salary,
);

Choose a reason for hiding this comment

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

According to the requirements, this function should return an array of employee objects matching the schema { name, position, salary, age }. Currently, it returns an array of DOM elements. You need to map over the filtered elements and construct an object for each employee with the required properties.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great work on this task! Your solution correctly implements all the requirements, and the sorting functionality works as expected. I am approving your submission.

As a point for future improvement, take a look at the comment regarding the sortList function. It currently depends on the global employees variable. While this works, making the function self-contained by having it operate only on data passed in as arguments is a best practice that makes code more predictable, reusable, and easier to test. This is not a blocker, but something to keep in mind as you write more complex code.

Keep up the excellent progress!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment on lines +47 to +49
const elNode = employees.find(
(employee) => employee.textContent.trim() === el.name,
);

Choose a reason for hiding this comment

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

The sortList function relies on the employees variable which is defined in the global scope (on line 57). This makes the function less predictable and harder to reuse because it depends on an external variable that isn't passed as a parameter.

A better approach is to make the function self-contained. For example, you could get the list of DOM nodes from the list parameter at the beginning of this function and use that local variable here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants