Skip to content

add task solution - #2062

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

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

Conversation

@Whitefyre

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 core requirements are not met and they affect correctness and compliance with the task specification. 1) On or around line 30 in src/scripts/main.js, the employee name is read via innerText, but the task requires using data attributes for employee information. Please use something like child.dataset.name instead, aligning with the schema used for other fields. 2) The salary string-to-number conversion is done inline within the sort logic; the task explicitly requires a dedicated helper function for this conversion. Extract the conversion into a reusable helper (e.g., parseSalary(s)), and use it where sorting and data extraction occur. Additionally, consider returning salary as a number in getEmployees for consistency with the data attribute–based schema and to avoid repeated conversions. Once these changes are made, your otherwise solid sorting and data retrieval logic should fully meet the requirements. Keep up the good work—your sorting by salary (descending) is implemented correctly and close to complete.


✨ 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 newArr = [];

for (const child of list.children) {
newArr.push({

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 using data attributes for employee information, but innerText is being used here. The name should come from a data attribute (e.g., child.dataset.name) rather than text content.

Comment thread src/scripts/main.js Outdated
for (const child of list.children) {
newArr.push({
element: child,
salary: Number(child.dataset.salary.replace(/[$,]/g, '')),

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 explicitly requires a 'helper function' for converting salary string to number, but this conversion is currently inline. Consider extracting it into a separate helper function as specified.

Comment thread src/scripts/main.js
newArr.push({
name: child.innerText,
position: child.dataset.position,
salary: child.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.

The salary in getEmployees is returned as a string, but since the employee schema should use data attributes consistently and other numeric values are stored, consider whether salary should be converted to a number here as well for consistency.

@Whitefyre

Copy link
Copy Markdown
Author

@mateacademy-ai-mentor I add helper function parseSalary(s). As for name: child.innerText, I can't just use name: child.dataset.name because that way I can only retrieve attributes that start with data-. and names is inner text Also, regarding the display of the salary in the getEmployees function, it would be very strange if the output showed, like, 123456 instead of $123,456, that would make it less readable.

@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 approving your solution because the core requirements are met: you implemented a dedicated parseSalary(s) helper, used it appropriately in sorting, and correctly extract name via innerText given the HTML structure. The list is sorted by salary in descending order and data attributes for position, salary, and age are handled correctly. One minor improvement for consistency and schema compliance: on lines 34–37, salary: child.dataset.salary returns a string; the requirement expects a numeric salary, so consider using salary: parseSalary(child.dataset.salary) to align with the helper and return a number. This is not a blocker if tests don’t enforce the numeric schema, but it’s recommended for correctness and consistency. Great work overall—clean implementation and thoughtful handling of the DOM structure.


✨ 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