Skip to content

solution#1888

Open
tavokina wants to merge 3 commits intomate-academy:masterfrom
tavokina:develop
Open

solution#1888
tavokina wants to merge 3 commits intomate-academy:masterfrom
tavokina:develop

Conversation

@tavokina
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

Great job on implementing the core logic for sorting and parsing the employee data! Your code works correctly, but it needs a few adjustments to meet all the task requirements. The sortList and getEmployees functions are required to accept a list parameter in their definitions, like sortList(list), but they currently rely on a global variable. Additionally, the task requires a dedicated helper function for converting the salary string to a number to avoid repeating that logic. Please create this helper and use it in both of your main functions. Once these changes are made, your solution will be complete!


✨ 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

// write code here
const list = document.querySelector('ul');

function sortList() {

Choose a reason for hiding this comment

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

According to the requirements, the sortList function should accept a list property as a parameter. It currently relies on the global list variable, which makes the function less reusable.

Comment on lines 10 to 11
Number(b.dataset.salary.replace('$', '')) -
Number(a.dataset.salary.replace('$', '')),

Choose a reason for hiding this comment

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

The task requires creating a helper function for converting the salary string to a number. This would help avoid repeating the conversion logic here and in the getEmployees function.

employees.forEach((employee) => list.append(employee));
}

function getEmployees() {

Choose a reason for hiding this comment

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

Similar to sortList, the requirements state that the getEmployees function should also accept a list property as a parameter.

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 done a great job implementing the helper function and refactoring your code to use parameters. There's just one small but important correction needed in the sortList function before this can be approved.

Currently, the function accepts listElement as a parameter but then uses the global list variable to append the sorted items. To make the function fully self-contained and reusable, it should operate only on the parameters it receives.

To fix this, please update the forEach loop inside sortList to append to the listElement parameter instead of the global list variable:

// Inside the sortList function
sortedEmployees.forEach((employee) => {
  listElement.append(employee); // Use the listElement parameter here
});

With that one change, your solution will be perfect. Keep up the great work!


✨ 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

(a, b) => convertString(b.dataset.salary) - convertString(a.dataset.salary),
);

employees.forEach((employee) => list.append(employee));

Choose a reason for hiding this comment

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

This line correctly appends the sorted employees. However, it uses the global list variable instead of the listElement parameter that was passed to the function. To make the function more robust and reusable, it should operate on the listElement parameter it receives.

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 work on this task! I am approving your solution as it perfectly meets all the requirements. You did a great job addressing the feedback from the previous review; the sortList function is now robust and correctly utilizes the parameter passed to it. The code is clean, well-structured, and functions exactly as expected. Keep up the fantastic work!


✨ 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