add task solution#1981
Conversation
Alibobick
commented
Apr 29, 2026
- DEMO LINK
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The implementation is functional but requires changes to meet requirement #9. The salary parsing logic (Number(a.dataset.salary.replace('\$', '').replace(',', ''))) is duplicated across lines 7, 8, and 22 instead of being extracted into a named helper function like parseSalary(salaryString). This checklist item explicitly requires creating this helper function to avoid code duplication. Please extract the salary-to-number conversion into a reusable helper function and use it in both sortList and getEmployees functions. Minor suggestion: consider renaming listElements to employeeList for clarity since it refers to a single <ul> element.
✨ 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
|
|
||
| function sortList(list) { | ||
| const sortedList = Array.from(list.querySelectorAll('li')).sort((a, b) => { | ||
| const salaryA = Number(a.dataset.salary.replace('$', '').replace(',', '')); |
There was a problem hiding this comment.
Requirement #9 specifies creating a helper function to convert salary string to number. Currently, the parsing logic Number(a.dataset.salary.replace('$', '').replace(',', '')) is duplicated across lines 7, 8, and 22. Extract this into a named helper function (e.g., parseSalary(salaryString)) for better code reuse.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation successfully meets all task requirements. The parseSalary helper function has been properly extracted and used in both sortList and getEmployees functions, eliminating code duplication as required. All core functionality is working correctly: the list is retrieved from the document, employees are sorted by salary in descending order, and employee objects contain all four required properties (name, position, salary, age). Both functions are properly called, and the sorted items are appended back to the DOM. The code is clean, well-structured, and ready for use.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨