Skip to content

Parse list#2001

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

Parse list#2001
balakhmei wants to merge 2 commits into
mate-academy:masterfrom
balakhmei:develop

Conversation

@balakhmei

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 implementation has critical bugs that must be fixed. Both sortList(listElement) and getEmployees(listElement) ignore their parameter and use a global list variable instead—this breaks the function contract and makes them non-reusable. Replace list.querySelectorAll('li') with listElement.querySelectorAll('li') in both functions. Additionally, getEmployees uses Number(li.dataset.salary) directly, but salary values contain commas (e.g., "$1,200") which causes Number() to return NaN—reuse your convertSalary helper function for consistent conversion. Finally, the age attribute is also a string and needs conversion to a number for proper schema compliance.


✨ 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

// write code here
function sortList(listElement) {
const items = Array.from(list.querySelectorAll('li'));

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 parameter is named listElement but the code uses global list variable. Use listElement.querySelectorAll('li') instead of list.querySelectorAll('li').

Comment thread src/scripts/main.js
return list.append(...sortSalary);
}

function getEmployees(listElement) {

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 same issue - should use listElement parameter instead of global list variable.

Comment thread src/scripts/main.js
const employee = items.map((li) => {
return {
name: li.dataset.name,
position: li.dataset.position,

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 salary data attribute contains '$' and ',' characters (e.g., '$1,200'). Calling Number() directly will return NaN. Reuse the convertSalary helper function or apply the same string-to-number conversion here.

Comment thread src/scripts/main.js Outdated
name: li.dataset.name,
position: li.dataset.position,
salary: Number(li.dataset.salary),
age: li.dataset.age,

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 age data attribute is a string. Convert it to a number for consistency with the schema requirements (all employee object values should be the correct types).

@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 requirements have been successfully implemented and all previously identified issues have been resolved. Both sortList and getEmployees functions now correctly use their listElement parameters, the convertSalary helper is properly reused, and the age attribute is correctly converted to a number. All 11 checklist items pass, and no test failures or build issues are reported.


✨ 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