add task solution#2022
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there is a critical functional issue: the Cypress test that checks sorting by salary in descending order is failing, and only 5 items remain in the list instead of all 10 after sortList runs. This means the sorting logic (or how items are handled during sorting) is breaking the DOM structure and violating the requirement that all employees stay in the list after sorting, which is a blocker for task completion. Please review your sortList(list) implementation in src/scripts/main.js and ensure that it:
- Converts
list.childrento an array, - Sorts all items by
data-salaryin descending order, - Re-appends every item back to the list without filtering or dropping any.
In addition, the task explicitly asks for a helper function to convert the salary string from the data attribute to a number [CHECKLIST ITEM #14]; you currently use parseInt inline, so factor that logic into a small helper such as getSalary(item) and reuse it in both getEmployees and sortList. On the positive side, you are correctly using dataset, building the employees array with the required fields, and calling both functions, so you are close—fixing the sorting bug and adding the helper will bring this fully in line with the requirements.
✨ 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
| const items = Array.from(list.children); | ||
|
|
||
| items.sort((a, b) => { | ||
| const salaryA = parseInt(a.dataset.salary, 10); |
There was a problem hiding this comment.
The task description explicitly asks for a helper function to convert the salary string from the data attribute to a number (checklist item #14). Here you directly use parseInt inline; consider extracting this conversion to a small helper function and reusing it in both getEmployees and sortList to match that requirement more literally.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because the current main.js fully meets the functional and technical requirements of the task. Your sortList(list) correctly converts list.children to an array, uses a dedicated getSalary(item) helper to parse numeric salaries from data-salary, sorts in descending order, and re-appends all items so none are dropped. Your getEmployees(list) builds and returns an array of employee objects with the required {name, position, salary, age} schema, using dataset for all non-standard attributes as required. Both functions are properly called after selecting the list from the document, so the behavior is wired up end-to-end.
Previously reported Cypress failures were caused by earlier logic, but the current implementation directly addresses those issues by ensuring correct numeric sorting and preserving all 11 items in the list. Remaining uncertainties (like whether you ran specific npm test commands or followed layout guidelines) are process-related and not blockers for this JavaScript task. Overall, this is a solid, clean implementation that aligns with the checklist and demonstrates good use of helpers and DOM APIs.
✨ 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.
DEMO LINK