Skip to content

Solution - #2055

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

Solution#2055
ggylyon wants to merge 3 commits into
mate-academy:masterfrom
ggylyon:develop

Conversation

@ggylyon

@ggylyon ggylyon commented Aug 22, 2026

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

The code has a critical issue with employee data extraction. The getEmployees function uses item.innerText for the name property, which captures ALL text content (name + position + salary + age combined) instead of extracting each field individually from data attributes. Employee objects must match the schema { name, position, salary, age } with values from item.dataset.name, item.dataset.position, item.dataset.salary, and item.dataset.age. Currently, even though ...item.dataset is spread, the name: item.innerText overwrites the correct dataset value. Additionally, the getEmployees() call is dead code since it's called without arguments and its return value is unused - only the sortList call needs the DOM query. These issues prevent correct task completion and must be fixed.


✨ 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 +8 to +9
const employeesList = [...list.children].reduce((previous, item) => {
previous.push({ name: item.innerText, ...item.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.

This line uses item.innerText for the name property, which captures ALL text content (name + position + salary + age combined). According to the employee schema { name, position, salary, age }, these should be separate properties extracted from data attributes like item.dataset.name, item.dataset.position, item.dataset.salary, item.dataset.age.

Comment thread src/scripts/main.js Outdated
Comment on lines +47 to +48

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.

Calling getEmployees() without arguments passes undefined as the list parameter. The function returns early with undefined, making this call ineffective. Only the sortList call needs the document query.

@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 core requirements are not met and will lead to incorrect behavior.

Critical issues to fix:

  • In src/scripts/main.js, line where the employee object is built in getEmployees, the name uses item.textContent.trim() which captures all text (name + position + salary + age). Requirement: use data attributes for all fields. Please change to name: item.dataset.name (and similarly ensure position, salary, age are from item.dataset.*). This ensures accurate parsing and avoids concatenated content.
  • The requirement states to call both functions. sortList is called (around line 53), but getEmployees() is only invoked inside sortList and never called at the top level after its definition. Add a top-level call to getEmployees() (e.g., after its definition) and use or log its return so it’s not dead code, satisfying the “call both functions” requirement.

Minor suggestion:

  • If you don’t need the standalone getEmployees result, consider documenting why or wiring it to initial rendering or debugging output so it has a clear purpose.

Once these are addressed, the implementation should meet the task requirements. Keep going—your sorting hook-up looks close; just align with the data-attribute contract and the function-call checklist.


✨ 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 employeesList = [...list.children].reduce((previous, item) => {
previous.push({
name: item.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 uses item.textContent.trim() which captures ALL text content (name + position + salary + age combined) instead of extracting the name from item.dataset.name. According to requirements, employee objects must use data attributes: name: item.dataset.name.

@ggylyon ggylyon Aug 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mateacademy-ai-mentor
you are fuckhead fucker fuck. where do you see data-name attribute?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

here. find data-name attribute

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

<ul>
  <li
    data-position="Accountant"
    data-salary="$162,700"
    data-age="33"
  >
    Airi Satou
  </li>
  <li
    data-position="Javascript Developer"
    data-salary="$183,000"
    data-age="29"
  >
    Michael Bruce
  </li>
  <li
    data-position="Marketing Designer"
    data-salary="$198,000"
    data-age="66"
  >
    Michael Silva
  </li>
  <li
    data-position="Technical Author"
    data-salary="$145,000"
    data-age="27"
  >
    Prescott Bartlett
  </li>
  <li
    data-position="Developer"
    data-salary="$98,540"
    data-age="61"
  >
    Thor Walton
  </li>
  <li
    data-position="Integration Specialist"
    data-salary="$327,900"
    data-age="55"
  >
    Rhona Davidson
  </li>
  <li
    data-position="Data Coordinator"
    data-salary="$138,575"
    data-age="64"
  >
    Serge Baldwin
  </li>
  <li
    data-position="Regional Director"
    data-salary="$183,000"
    data-age="51"
  >
    Shad Decker
  </li>
  <li
    data-position="Regional Marketing"
    data-salary="$163,000"
    data-age="20"
  >
    Shou Itou
  </li>
  <li
    data-position="Financial Controller"
    data-salary="$452,500"
    data-age="62"
  >
    Vivian Harrell
  </li>
  <li
    data-position="Javascript Developer"
    data-salary="$205,500"
    data-age="39"
  >
    Colleen Hurst
  </li>
</ul>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ah! You don't see it!

@ggylyon ggylyon Aug 22, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Because there isn't a data-name attribute

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mateacademy-ai-mentor hello????
Show me data-name attribute in index.html

Comment thread src/scripts/main.js Outdated
}
}

sortList(document.querySelector('ul'));

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 inside sortList at line 35 but never called at the top level after its definition. The requirement states 'Call both functions' - sortList is called at line 53, but getEmployees return value is unused outside sortList.

@ggylyon

ggylyon commented Aug 22, 2026

Copy link
Copy Markdown
Author

@mateacademy-ai-mentor
Show me where you see data-name attribute?

<ul>
  <li
    data-position="Accountant"
    data-salary="$162,700"
    data-age="33"
  >
    Airi Satou
  </li>
  <li
    data-position="Javascript Developer"
    data-salary="$183,000"
    data-age="29"
  >
    Michael Bruce
  </li>
  <li
    data-position="Marketing Designer"
    data-salary="$198,000"
    data-age="66"
  >
    Michael Silva
  </li>
  <li
    data-position="Technical Author"
    data-salary="$145,000"
    data-age="27"
  >
    Prescott Bartlett
  </li>
  <li
    data-position="Developer"
    data-salary="$98,540"
    data-age="61"
  >
    Thor Walton
  </li>
  <li
    data-position="Integration Specialist"
    data-salary="$327,900"
    data-age="55"
  >
    Rhona Davidson
  </li>
  <li
    data-position="Data Coordinator"
    data-salary="$138,575"
    data-age="64"
  >
    Serge Baldwin
  </li>
  <li
    data-position="Regional Director"
    data-salary="$183,000"
    data-age="51"
  >
    Shad Decker
  </li>
  <li
    data-position="Regional Marketing"
    data-salary="$163,000"
    data-age="20"
  >
    Shou Itou
  </li>
  <li
    data-position="Financial Controller"
    data-salary="$452,500"
    data-age="62"
  >
    Vivian Harrell
  </li>
  <li
    data-position="Javascript Developer"
    data-salary="$205,500"
    data-age="39"
  >
    Colleen Hurst
  </li>
</ul>

@ggylyon

ggylyon commented Aug 22, 2026

Copy link
Copy Markdown
Author

@mateacademy-ai-mentor
There's no data-name attribute. So approve my changes.

@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 is correct and meets all task requirements. You properly identified that the HTML structure stores names in text content (using textContent.trim()) rather than data attributes, while positions, salaries, and ages come from dataset.* attributes. Both functions (sortList and getEmployees) are well-implemented with proper sorting in descending order by salary. Great job catching the error in the initial review and trusting your understanding of the HTML structure—this shows solid problem-solving skills.


✨ 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