Skip to content

feat: sorting list of people by their salary#1925

Open
dmytro-halieba wants to merge 1 commit intomate-academy:masterfrom
dmytro-halieba:develop
Open

feat: sorting list of people by their salary#1925
dmytro-halieba wants to merge 1 commit intomate-academy:masterfrom
dmytro-halieba:develop

Conversation

@dmytro-halieba
Copy link

Copy link

@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

Good job implementing the visual sorting of the employee list! The logic works correctly. However, this requires changes because the getEmployees function doesn't meet a core requirement from the task description. It should return an array of JavaScript objects, each with name, position, salary, and age properties, but it currently returns an array of DOM elements.

Please modify the function to iterate over the list items, create an object for each one, and extract the necessary data from its text and data-* attributes. You're very close to completing the task!


✨ 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 on lines +6 to +15
function getEmployees() {
const collection = document.getElementsByTagName('li');
const list = [];

for (let i = 0; i < collection.length; i++) {
list.push(collection.item(i));
}

return list;
}

Choose a reason for hiding this comment

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

This function does not meet the requirements from the task description (Step 3). It should accept a list of DOM elements as an argument and return an array of JavaScript objects, where each object represents an employee with name, position, salary, and age properties. The current implementation returns an array of DOM elements instead.

Comment on lines +20 to +21
const salary1 = salaryNormilaze(employee1['attributes']['data-salary']['value']);
const salary2 = salaryNormilaze(employee2['attributes']['data-salary']['value']);

Choose a reason for hiding this comment

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

This works for getting the salary value. As a suggestion for cleaner code, you can use the dataset property to access data-* attributes directly, for example: employee1.dataset.salary.

Comment on lines +45 to +47
for (let i = 0; i < sortedList.length; i++) {
document.getElementsByTagName('li')[i].outerHTML = sortedList[i].outerHTML;
}

Choose a reason for hiding this comment

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

The task requires you to 'Append sorted items to list'. This code replaces the HTML of existing elements. A more direct and safer way to meet this requirement is to get the parent <ul> container, clear its current content (e.g., ul.innerHTML = ''), and then loop through your sortedList array, appending each <li> element using ul.appendChild(li).

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