solution - #2067
Conversation
kristinakovalchuk
commented
Sep 6, 2026
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
This implementation has three critical blockers that must be fixed:
-
Incomplete employee schema (line ~19): The
getEmployeesfunction returns{name, salary}but the task requires{name, position, salary, age}. You need to extractpositionandagefrom the list item's content. -
Missing required helper function: The task explicitly requires a
parseSalaryor similar helper function to convert salary strings to numbers, but the code uses inlineNumber(...)conversions instead. Extract this into a reusable function that bothsortListandgetEmployeescan use. -
Bug: wrong variable used (line ~19): Uses global
listinstead of the parameterlistElement. Should beArray.from(listElement.children)to match howsortListuses its parameter. -
Test failure: The
should be sorted by salary DSCtest is failing (expected10, got5), indicating the sorting functionality is broken. The salary values aren't being sorted in descending order correctly.
Please address these issues before resubmitting.
✨ 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 getEmployees(listElement) { | ||
| return Array.from(list.children).map((li) => { | ||
| return { | ||
| name: li.textContent.trim(), | ||
| salary: Number((li.dataset.salary || '').replace(/,/g, '')), | ||
| }; | ||
| }); |
There was a problem hiding this comment.
The employee object only returns {name, salary}, but the task requires schema {name, position, salary, age}. You need to extract position and age from the list item's content and include them in the returned object.
| const salaryA = Number((a.dataset.salary || '').replace(/,/g, '')); | ||
| const salaryB = Number((b.dataset.salary || '').replace(/,/g, '')); |
There was a problem hiding this comment.
The task requires a helper function to convert salary string to number. Currently the conversion logic is duplicated inline. Extract this into a separate parseSalary or similar helper function that both sortList and getEmployees can use.
| } | ||
|
|
||
| function getEmployees(listElement) { | ||
| return Array.from(list.children).map((li) => { |
There was a problem hiding this comment.
Bug: Uses global list variable instead of the function parameter listElement. Should be Array.from(listElement.children) to be consistent with how sortList uses its parameter.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because a core requirement is missing and tests are failing. The task requires a reusable helper to parse salaries, but the code currently parses salaries inline in multiple places (e.g., around lines 7-8 and 23) and uses inconsistent regex patterns ([$,] vs ,). This inconsistency can lead to incorrect numeric values and breaks the requirement for a single helper function. Additionally, the Cypress test “Parse list app — should be sorted by salary DSC” fails, indicating the list is not properly sorted in descending numeric order—likely due to improper or inconsistent salary parsing.
Critical issues to fix:
- Implement a shared
parseSalaryhelper (e.g.,parseSalary(str)) that strips currency symbols/commas and converts to a number, and use it in bothsortListandgetEmployeesto ensure consistent parsing. For example:Number((str || '').replace(/[^ \d.-]/g, ''))or at least remove[$,]consistently. - Ensure sorting uses numeric comparison with the parsed salaries and orders by descending:
items.sort((a, b) => parseSalary(b) - parseSalary(a)). Verify all list items are re-appended in the correct order and the full length remains intact.
Minor: If salaries can include symbols or spaces, make the helper robust by removing all non-numeric characters except sign/decimal. Great job on handling descending logic conceptually and returning complete employee objects—once the helper is added and used consistently, the tests should pass. Keep going—you’re close!
✨ 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 salaryA = Number((a.dataset.salary || '').replace(/,/g, '')); | ||
| const salaryB = Number((b.dataset.salary || '').replace(/,/g, '')); |
There was a problem hiding this comment.
The task requires a helper function for parsing salary (string to number conversion). Currently salary parsing is done inline with Number((a.dataset.salary || '').replace(/,/g, '')). Extract this into a reusable parseSalary function that both sortList and getEmployees can call.
| return { | ||
| name: li.textContent.trim(), | ||
| position: li.dataset.position, | ||
| salary: Number((li.dataset.salary || '').replace(/[$,]/g, '')), |
There was a problem hiding this comment.
Salary parsing is duplicated inline. Also note the regex differs from line 23: [$,] vs ,. A helper function would ensure consistent parsing.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation is complete and correct. The shared parseSalary helper is properly implemented and used consistently in both sortList and getEmployees, ensuring clean, maintainable code. The descending sort correctly uses numeric comparison, and all employee objects include the required name, position, salary, and age fields. Great work resolving the previous issues and following the schema requirements. Keep this pattern of extracting reusable logic into helper functions - it makes your code more testable and easier to maintain.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨