Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
src/scripts/main.js
Outdated
| return [...list.childNodes].filter( | ||
| (el) => el.nodeType === 1 && el.dataset.salary, | ||
| ); |
There was a problem hiding this comment.
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.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| const elNode = employees.find( | ||
| (employee) => employee.textContent.trim() === el.name, | ||
| ); |
There was a problem hiding this comment.
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.
Is this really optimal? Why not use that querySelectorAll inside a list, apart from other things?