Parse list#2001
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation has critical bugs that must be fixed. Both sortList(listElement) and getEmployees(listElement) ignore their parameter and use a global list variable instead—this breaks the function contract and makes them non-reusable. Replace list.querySelectorAll('li') with listElement.querySelectorAll('li') in both functions. Additionally, getEmployees uses Number(li.dataset.salary) directly, but salary values contain commas (e.g., "$1,200") which causes Number() to return NaN—reuse your convertSalary helper function for consistent conversion. Finally, the age attribute is also a string and needs conversion to a number for proper schema compliance.
✨ 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
|
|
||
| // write code here | ||
| function sortList(listElement) { | ||
| const items = Array.from(list.querySelectorAll('li')); |
There was a problem hiding this comment.
The parameter is named listElement but the code uses global list variable. Use listElement.querySelectorAll('li') instead of list.querySelectorAll('li').
| return list.append(...sortSalary); | ||
| } | ||
|
|
||
| function getEmployees(listElement) { |
There was a problem hiding this comment.
The same issue - should use listElement parameter instead of global list variable.
| const employee = items.map((li) => { | ||
| return { | ||
| name: li.dataset.name, | ||
| position: li.dataset.position, |
There was a problem hiding this comment.
The salary data attribute contains '$' and ',' characters (e.g., '$1,200'). Calling Number() directly will return NaN. Reuse the convertSalary helper function or apply the same string-to-number conversion here.
| name: li.dataset.name, | ||
| position: li.dataset.position, | ||
| salary: Number(li.dataset.salary), | ||
| age: li.dataset.age, |
There was a problem hiding this comment.
The age data attribute is a string. Convert it to a number for consistency with the schema requirements (all employee object values should be the correct types).
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
All requirements have been successfully implemented and all previously identified issues have been resolved. Both sortList and getEmployees functions now correctly use their listElement parameters, the convertSalary helper is properly reused, and the age attribute is correctly converted to a number. All 11 checklist items pass, and no test failures or build issues are reported.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
DEMO LINK