Skip to content

Firt task Solution#4981

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

Firt task Solution#4981
jkumorek01 wants to merge 2 commits into
mate-academy:masterfrom
jkumorek01:develop

Conversation

@jkumorek01

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

I am requesting changes because, while your convertToObject implementation works correctly for the given CSS string, it currently violates two explicit checklist requirements, which are considered critical blockers. First, the variable named result in src/convertToObject.js (around the top of the function) conflicts with [CHECKLIST ITEM #2], which asks you to avoid generic names like array, object, arr, obj, or result; please rename it to something domain-specific such as stylesObject or cssStylesMap to better describe the stored data. Second, inside the forEach that processes the style declarations, you are mutating the result object via result[left] = right;, which breaks [CHECKLIST ITEM #1] that requires using iteration methods (e.g. reduce) to build and return new objects rather than mutating existing ones. A good way to fix this is to replace the forEach with a reduce over the declarations array and return the accumulated object directly, ensuring you are not modifying an outer-scoped object. Functionally your solution is solid and correctly parses the CSS string, so once you address these checklist violations, your code will meet both the behavioral and style requirements. Keep going—your logic is on the right track, and these changes will help align it with the project's standards.


✨ 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/convertToObject.js Outdated
function convertToObject(sourceString) {
// write your code here
const elements = sourceString.split(';');
const result = {};

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 violates checklist item #2: Avoid variable namings like array , object arr, obj, result. It will decrease code readability because the variable is named result. Consider renaming it to something more descriptive of its content, like stylesObject or similar.

Comment thread src/convertToObject.js Outdated
Comment on lines +12 to +21
elements.forEach((x) => {
if (x.trim() === '') {
return;
}

const parts = x.trim().split(':');
const left = parts[0].trim();
const right = parts[1].trim();

result[left] = right;

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 violates checklist item #1: Don't use iteration methods to modify an already existing array/object. (forEach is exception). These methods return a new array, so you should use it. Here forEach is used to mutate the result object (result[left] = right;). You should instead use an iteration method (like reduce) to build and return a new object without mutating an existing one.

@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 because it correctly implements convertToObject according to the task requirements and behaves as expected for the provided style strings. The function cleanly parses the CSS-style input into an object of key/value pairs, including all properties from the more complex example, without any missing or incorrect mappings. You appropriately use reduce to build and return a new stylesObject, satisfying the constraint of avoiding loops and not mutating an existing object [CHECKLIST ITEM #X]. The naming is domain-specific and clear, and there are no indentation or chained-method style issues that would violate the checklist. I don’t see any critical or blocking problems with functionality or requirements, so you’ve met the standard for this task. Nice work applying the feedback and refining your implementation; this is a solid, idiomatic JavaScript solution.


✨ 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