Skip to content

add task solution#1981

Open
Alibobick wants to merge 2 commits into
mate-academy:masterfrom
Alibobick:develop
Open

add task solution#1981
Alibobick wants to merge 2 commits into
mate-academy:masterfrom
Alibobick:develop

Conversation

@Alibobick
Copy link
Copy Markdown

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js Outdated

function sortList(list) {
const sortedList = Array.from(list.querySelectorAll('li')).sort((a, b) => {
const salaryA = Number(a.dataset.salary.replace('$', '').replace(',', ''));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants