Skip to content

implement convertToObject#4972

Open
IvanKhyzhniak wants to merge 1 commit into
mate-academy:masterfrom
IvanKhyzhniak:master
Open

implement convertToObject#4972
IvanKhyzhniak wants to merge 1 commit into
mate-academy:masterfrom
IvanKhyzhniak:master

Conversation

@IvanKhyzhniak

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 function produces the correct output, it currently violates explicit checklist constraints that are considered core requirements for this task. In src/convertToObject.js, you build the styles object by first declaring it outside the iteration and then mutating it inside a for...of loop; this conflicts with the requirement to (1) avoid mutating an already existing object via iteration methods [CHECKLIST ITEM #1] and (2) avoid using loops in favor of array iteration methods like reduce [CHECKLIST ITEM #5]. To fix this, refactor the code so that you call something like declarations.reduce(...) and return the accumulated styles object from the reducer, instead of modifying an external styles variable inside a loop.

Additionally, your JSDoc uses @return {object}, which goes against the guideline to avoid the generic object name [CHECKLIST ITEM #2]; update it to a more explicit structural type, for example @return {{[key: string]: string}}, or another clear shape that describes the returned object. The parsing logic itself—splitting on ;, filtering out empty entries, splitting on :, trimming key and value—is solid and aligns well with the functional requirements. Once you switch to an iteration method-based approach and adjust the JSDoc type, your solution will meet both the functional and checklist requirements, and you’ll be in great shape.


✨ 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
*/
function convertToObject(sourceString) {
// write your code here
const styles = {};

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 initializes an external object and later gets mutated inside the loop. This conflicts with checklist item #1: "Don't use iteration methods to modify an already existing array/object"—for this task you should build the object via the return value of an iteration method (like reduce) rather than mutate an external accumulator.

Comment thread src/convertToObject.js
.split(';')
.filter(piece => piece.trim());

for (const declaration of declarations) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using a for ... of loop violates checklist item #5: "Avoid using loops in this task, use iteration methods instead." Consider using reduce (or similar) on declarations to build and return the styles object.

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