Skip to content

check#1919

Open
OliverBars wants to merge 2 commits intomate-academy:masterfrom
OliverBars:develop
Open

check#1919
OliverBars wants to merge 2 commits intomate-academy:masterfrom
OliverBars:develop

Conversation

@OliverBars
Copy link

No description provided.

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

This requires a few changes to meet the task requirements. You've made a good start by selecting the elements and implementing sorting logic, but there are three main issues to address: 1. Your code is currently in the global scope, but it needs to be placed inside the two required functions: sortList and getEmployees. 2. The list is sorted in ascending order, but the requirement is to sort in descending order (highest salary first). You can fix this by reversing the logic in your sort comparison. 3. The getEmployees function, which should parse the list and return an array of employee objects, is currently missing and needs to be implemented. Addressing these critical points will align your solution 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines 4 to 16

const list = document.querySelector('ul');
const items = [...document.querySelectorAll('li')];

items.sort((a, b) => {
const getNumericSalary = (el) => {
return parseFloat(el.dataset.salary.replace(/[^0-9.-]+/g, ''));
};

return getNumericSalary(a) - getNumericSalary(b);
});

items.forEach((item) => list.appendChild(item));

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 create two functions, sortList and getEmployees, and place your logic within them. Currently, the code is in the global scope.

return parseFloat(el.dataset.salary.replace(/[^0-9.-]+/g, ''));
};

return getNumericSalary(a) - getNumericSalary(b);

Choose a reason for hiding this comment

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

This expression sorts the items in ascending order. The requirement is to sort them in descending order.

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

Excellent progress on this task! You've correctly implemented the sorting logic and structured the code well. However, a few changes are needed to meet all the requirements before this can be approved.

Here are the key things to address:

  1. Function Parameters: Both getEmployees and sortList must be updated to accept a list as a parameter, as specified in the requirements.
  2. Incorrect Object Schema: The getEmployees function needs to return objects that match the required { name, position, salary, age } schema. You'll need to parse the name, position (from the text content), and age (from the data-age attribute) for each item.
  3. Missing Helper Function: The salary parsing logic (line 10) should be extracted into its own separate helper function.

Addressing these points will complete the task. You're very 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment on lines +5 to +12
const getEmployees = () => {
const items = [...document.querySelectorAll('li[data-salary]')];

return items.map((item) => ({
element: item,
salary: parseFloat(item.dataset.salary.replace(/[^0-9.-]+/g, '')),
}));
};

Choose a reason for hiding this comment

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

This function is on the right track, but it needs a few adjustments to meet all requirements:

  1. It should accept a list as a parameter.
  2. The returned objects should match the { name, position, salary, age } schema. You'll need to parse the name, position (from the text content), and age (from the data-age attribute) for each item. The element property is not part of the required schema.
  3. The salary parsing logic on line 10 should be extracted into a separate helper function.

Comment on lines +14 to +21
const sortList = () => {
const list = document.querySelector('ul');
const employees = getEmployees();

employees.sort((a, b) => b.salary - a.salary);

employees.forEach((obj) => list.appendChild(obj.element));
};

Choose a reason for hiding this comment

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

This function also needs to accept a list as a parameter to meet the requirements.

Also, note that your current implementation relies on getEmployees returning DOM elements. Once you update getEmployees to return only data objects as required, this sorting logic will need to be revised. The sortList function should sort the <li> elements directly.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

lgtm

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.

3 participants