Skip to content

add solution#2025

Open
vladyslav-kukhar wants to merge 1 commit into
mate-academy:masterfrom
vladyslav-kukhar:develop
Open

add solution#2025
vladyslav-kukhar wants to merge 1 commit into
mate-academy:masterfrom
vladyslav-kukhar:develop

Conversation

@vladyslav-kukhar

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 two checklist-driven requirements about function signatures are not yet met and will likely break the tests. Specifically, sortList and getEmployees are required to accept a list parameter ([CHECKLIST ITEM #3] and [CHECKLIST ITEM #5]), but your current implementations have no parameters and instead rely on outer-scope variables; this is a critical mismatch with the spec and will cause the automated checks to fail. To fix this, refactor sortList(list) so it derives its li items from the passed-in list (e.g., via list.querySelectorAll('li')) and call it as sortList(list) where you currently call sortList(). Similarly, refactor getEmployees(list) to read items from the given list rather than from the original items NodeList, and then call it as getEmployees(list); this will also ensure you’re working with the actual sorted DOM. In addition, please parse dataset.salary to a number when building employee objects so the salary field is numeric and consistent with how you handle salary during sorting, ideally via a small helper like parseSalary(value) reused in both sorting and employee creation. The core logic and overall structure are solid, so once these signature and data-handling fixes are in place, your solution should fully satisfy the task requirements. Keep going—these are targeted adjustments, and you’re very close to a complete and robust implementation.


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

function sortList() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sortList is required to take a list parameter (checklist item #3), but here it has no arguments and relies on outer variables. Refactor it to accept list and derive its items inside the function.

Comment thread src/scripts/main.js
const itemsArr = [...items];

itemsArr.sort((a, b) => {
const salaryA = Number(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here you convert salary to a number inline; consider moving this logic into a small helper function as hinted in the description, which can be reused in both sorting and employee creation.

Comment thread src/scripts/main.js

sortList();

function getEmployees() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

getEmployees should take a list parameter (checklist item #5) and derive items from that list, but currently has no parameters and uses the outer items NodeList. Update the signature and implementation to work from the passed list.

Comment thread src/scripts/main.js
const user = {
name: item.textContent.trim(),
position: item.dataset.position,
salary: item.dataset.salary,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Salary is taken directly from dataset.salary as a string. Given the emphasis on converting salary from data attributes to numbers, consider parsing this to a number for the employee object to better match the intended schema.

Comment thread src/scripts/main.js
return result;
}

getEmployees();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

getEmployees is called without a list argument, but the requirements specify that it should take a list property. After changing the function signature, call it as getEmployees(list).

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