Solution#1973
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there are a few contract-breaking issues in src/scripts/main.js and the PR also touches files that were supposed to remain unchanged.
The critical functional issue is in sortList(listData) in src/scripts/main.js: inside the function you append the sorted <li> elements to the outer list variable instead of the listData parameter, which means the function relies on a specific global and does not behave correctly if called with any other list; update the forEach so it appends to listData (e.g. items.forEach(item => listData.appendChild(item))). Another core issue is in getEmployees(listData), where you build the name field using li.innerText; depending on the markup, this can include position, age, and salary text, so you should instead select the specific child that contains the name, for example li.querySelector('.name').textContent.trim() or whatever selector matches your HTML. There is also a checklist violation: the task required changing only main.js, but this PR includes additional changes (e.g. README.md, package.json, and workflow files), so those extra modifications need to be reverted or moved to a separate branch/PR. If tests expect numeric ages, you should also ensure age is converted with Number(li.dataset.age) instead of leaving it as a string.
Overall, your salary parsing, sorting logic, and the general structure of sortList and getEmployees look solid, so once you wire the functions to their parameters correctly, narrow the name selector, and limit changes to main.js, the solution will align well 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(listData.children); | ||
|
|
||
| items.sort((a, b) => getSalary(b) - getSalary(a)); | ||
| items.forEach((item) => list.appendChild(item)); |
There was a problem hiding this comment.
The code appends sorted items to the outer list variable instead of the function parameter listData. To respect the function contract and avoid relying on the global variable, append items to listData (for example: items.forEach(item => listData.appendChild(item))).
| function getEmployees(listData) { | ||
| return Array.from(listData.children).map((li) => { | ||
| return { | ||
| name: li.innerText, |
There was a problem hiding this comment.
Using li.innerText for the name field may capture other text from the whole list item (position, age, salary) depending on the markup. Select the specific child element that contains the name (for example li.querySelector('.name').innerText or the appropriate selector in your HTML) to ensure name contains only the person's name.
https://br0no.github.io/js_task_parse_list_DOM/