Skip to content

Tasks complited - #2056

Open
GrizlixXx wants to merge 3 commits into
mate-academy:masterfrom
GrizlixXx:develop
Open

Tasks complited#2056
GrizlixXx wants to merge 3 commits into
mate-academy:masterfrom
GrizlixXx:develop

Conversation

@GrizlixXx

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

I am requesting changes because core task requirements are not implemented as specified. In src/scripts/main.js: (1) The task requires a function sortList(list), but the sorting logic is executed at the top level instead of inside a sortList function. Please wrap the existing sort logic into function sortList(list) { ... return sortedList; } and ensure it accepts a list parameter. (2) The task requires getEmployees(list) that returns an array of employee objects; currently employees is created at the top level. Extract this logic into function getEmployees(list) { ... return employees; } and use the passed-in list. (3) The salary string-to-number conversion using .replace(...) is inline; move this into a helper, e.g., function parseSalary(value) { ... }, and call it inside getEmployees. (4) The task requires calling both functions; update the top-level code to call getEmployees(list) first, then pass the result to sortList(list) (or vice versa as required), and use the returned values.

Minor note: Keep side effects minimal at the top level; rely on returned values from the functions for clarity and testability. You’re close—your logic appears correct, but restructuring into the required functions will satisfy the specification and make the code easier to test and maintain.


✨ 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
Comment on lines +12 to +16
const sortedBySalary = [...employees].sort((a, b) => {
return (
Number(b.salary.replace('$', '').replace(',', '')) -
Number(a.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.

The task requires a function named sortList that takes a list parameter. Currently, there's no such function - the sorting logic is at the top level. Create the required function structure.

Comment thread src/scripts/main.js Outdated
Comment on lines +5 to +9
const employees = Array.from(listItems).map((li) => {
return {
name: li.textContent.trim(),
...li.dataset,
};

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 a function named getEmployees that takes a list parameter and returns an array of employee objects. Currently, employees is created at the top level without being in a function. Extract this into the required function.

Comment thread src/scripts/main.js Outdated

const sortedBySalary = [...employees].sort((a, b) => {
return (
Number(b.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.

The task requires a helper function for converting salary string to number. The .replace('$', '').replace(',', '') logic is inline but should be extracted into a helper function as specified.

Comment thread src/scripts/main.js Outdated
Comment on lines +21 to +33
list.innerHTML = sortedBySalary
.map((employee) => {
return `
<li
data-position="${employee.position}"
data-salary="${employee.salary}"
data-age="${employee.age}"
>
${employee.name}
</li>
`;
})
.join('');

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 calling both functions. The current code executes at the top level without proper function calls to sortList and getEmployees.

@GrizlixXx

Copy link
Copy Markdown
Author

Я поспорю з тобою і скажу що то була рекомендаційна інструкція тобто я не мусив робити функцію для сортування і інших дій то просто підсказка як можна було зробити завдання але я вирішив його зробити по свойому код працює програма виконує одинаковий результат тому не бачу причин відмовляти мені я вважаю що мій код кращий ніж запропонований в інструкції

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

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.

@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 implementation correctly meets all requirements. The employee objects properly derive their name, position, salary, and age properties from li.dataset through the spread operator. While there's a redundant line setting name: li.textContent.trim() before the spread, it has no functional impact since the spread overwrites it with the correct li.dataset.name value. The parseSalary, sortList, and getEmployees functions all work as specified. Great work on completing this task!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/scripts/main.js
Comment on lines +23 to +24
return listItems.map((li) => ({
name: li.textContent.trim(),

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 name property is being set to li.textContent.trim() which includes all visible text content (name + position + salary + age). Since li.dataset already contains name, position, salary, and age as separate properties, the employee object should use li.dataset.name instead of text content.

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