Skip to content

add task solution#2005

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

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

Conversation

@NeustrVk

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Your solution requires changes to meet the task requirements. There are two critical issues: First, the getEmployees function is missing the required position field — the employee schema requires objects with { name, position, salary, age }, but currently only name, salary, and age are being returned. You need to extract the position value from each list item's text content (using querySelector or textContent parsing). Second, salary and age are being returned as strings, but the schema requires these as numbers — use Number() or parseInt() to convert them when building the employee objects. Additionally, while less critical, the sortList function signature should only take list as a parameter, and the append logic should be handled within the function itself rather than externally.


✨ 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
const ul = document.querySelector('ul');
const liElements = [...document.querySelectorAll('li')];

function sortList(list, property) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The task requires sortList to take only a list property as parameter, but this function uses two parameters (list, property). Consider simplifying the signature or ensuring the second parameter usage matches requirements.

Comment thread src/scripts/main.js
Comment on lines +17 to +32
function getEmployees(list) {
const employees = [];

for (const li of list) {
const employee = {};

employee.name = li.textContent.trim();

for (const key in li.dataset) {
employee[key] = li.dataset[key];
}

employees.push(employee);
}

return employees;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The getEmployees function should return objects matching the schema: { name, position, salary, age }. Currently the returned objects include name, salary, and age, but position is missing. Extract the position value from the list item's text content (e.g., using querySelector or textContent parsing).

Comment thread src/scripts/main.js Outdated
Comment on lines +24 to +26

for (const key in li.dataset) {
employee[key] = li.dataset[key];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When building employee objects, li.dataset[key] values are strings. Per the schema requirements, salary and age should be numbers. Use Number() or parseInt() to convert these values when assigning to the employee object.

Comment thread src/scripts/main.js Outdated
Comment on lines +6 to +10
function sortList(list, property) {
return list.sort(
(li1, li2) =>
strToNumber(li2.dataset[property]) - strToNumber(li1.dataset[property]),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The sortList function should append sorted items to the list internally. Currently items are sorted and returned, but the append happens separately on lines 35-36. The requirement states the function should 'append sorted items to list', which should happen within sortList itself.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

All task requirements have been successfully implemented: the getEmployees function now includes all four required fields (name, position, salary, age) with proper numeric conversion, the sortList function correctly sorts employees by salary in descending order using the strToNumber helper, and both functions are properly invoked. The previous issues with the missing position field and string values have been resolved. Great work on addressing all the feedback and ensuring the code meets the specifications.


✨ 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