Skip to content

add solution - #2070

Open
justnicko wants to merge 2 commits into
mate-academy:masterfrom
justnicko:desktop
Open

justnicko wants to merge 2 commits into
mate-academy:masterfrom
justnicko:desktop

Conversation

@justnicko

Copy link
Copy Markdown

No description provided.

@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 parseSalary function has a critical issue that violates a core requirement. While it successfully removes currency symbols and commas, it returns a string instead of a number as explicitly required by the task. You need to convert the cleaned string to an actual number using Number() or the unary plus operator (+). For example: return Number(cleaned.replace(/[$,]/g, '')); or return +cleaned.replace(/[$,]/g, '');. This matters because salary comparisons in sorting and any arithmetic operations will fail with string values instead of numbers.


✨ 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 +43 to +44
function parseSalary(salary) {
return salary.replaceAll(/,|\$/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 parseSalary function returns a string after removing $ and commas, but the task explicitly requires 'Converts salary from string to number'. The returned salary in employee objects and the sorting comparison should use actual numbers. Wrap the result with Number() or use unary plus to convert it to a number type.

@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 solution is approved. You correctly implemented sortList and getEmployees, invoked them, and ensured salary sorting is done numerically in descending order by converting salary strings to numbers (using the unary + with a cleaned string). The employee objects contain the required fields (name, position, salary, age) and are derived from the list’s dataset and text as expected. Functionality appears robust and meets the task requirements without critical issues.

Minor suggestions (non-blocking): consider trimming the employee name (e.g., textContent.trim()) to avoid stray whitespace, and double-check the README/demo link replacement outside of JS if that was part of your task instructions. Nice work keeping the code clear and focused on the requirements.


✨ 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