solution task js_style-to-object#4980
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there are still critical requirement and checklist violations that affect the core behavior of your function. The task explicitly states that the function must preserve the full value string exactly as in the styles input, including internal spaces and !important, but your current implementation trims the value (valor.trim()), which can alter trailing or leading spaces that may be significant. To fix this, adjust how you extract the value substring: only remove whitespace that is clearly structural around the colon/semicolon, and avoid trimming away any other spaces in the value part itself.
In addition, there is a naming issue linked to [CHECKLIST ITEM #2]: the accumulator stylesObjeto is effectively just “object” in another language, and sourceString is close to the discouraged generic result/object-style naming. These should be renamed to more domain-specific, descriptive names such as cssStylesMap or stylesByProperty and something like stylesInput for the original string, which will improve readability and align with the checklist. Once you preserve the exact value strings and update the variable names to comply with the checklist, your solution will fully meet the requirements. You’ve done a good job with parsing logic and use of map/filter/reduce, so you’re close—these changes will complete the task solidly.
✨ 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
| .reduce((stylesObjeto, atualLine) => { | ||
| const [chave, valor] = atualLine.split(':'); | ||
|
|
||
| stylesObjeto[chave.trim()] = valor.trim(); |
There was a problem hiding this comment.
This violates the requirement that "The function must preserve the full value string as in the styles input, including internal spaces and !important where present" because valor.trim() removes leading/trailing spaces which may be significant in the value string (e.g. around !important). Consider only trimming around the colon or preserving the original value substring without extra trimming beyond what’s necessary to remove surrounding whitespace introduced by the split.
| .split(';') | ||
| .map((codeCss) => codeCss.trim()) | ||
| .filter((trimCodeCss) => trimCodeCss.includes(':')) | ||
| .reduce((stylesObjeto, atualLine) => { |
There was a problem hiding this comment.
This violates checklist item #2: "Avoid variable namings like array , object arr, obj, result. It will decrease code readability". The accumulator stylesObjeto is effectively the result object and the name is just "object" in another language; consider using a more descriptive name tied to its role (e.g. cssStylesMap or similar) to better reflect semantics.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there are still critical requirement violations that block this task from being fully correct. The function is required to preserve the full value string exactly as in the styles input, but at the point where you extract value (around the src/convertToObject.js line where you do const value = valuePart.trim() or similar), trimming removes meaningful leading/trailing spaces and can alter values like "left !important", which breaks the core specification. You need to adjust the value extraction so that you only remove clearly structural whitespace around the colon or semicolon, while keeping the substring of the value itself exactly as it appears in the original styles string (no .trim() on the value segment). In addition, the variable names such as sourceString and stylesObject are still too generic per the checklist; please rename them to more domain-specific names like stylesInput and stylesByProperty to better convey their role in parsing CSS styles. These two points—value preservation and naming—are both explicitly required and must be fixed before this solution can be considered complete. Once you address the value handling and improve the variable naming, the rest of your implementation (use of split/map/filter/reduce without loops and skipping empty declarations) is solid and should meet all the task constraints. Keep going—you’re very close; these targeted adjustments will bring your solution fully in line with the requirements.
✨ 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
| const [key, value] = currentLine.split(':'); | ||
|
|
||
| stylesObject[key.trim()] = value.trim(); |
There was a problem hiding this comment.
This still violates the core requirement that the function "must preserve the full value string exactly as in the styles input" and the previous HIGH-priority correction: calling value.trim() removes leading/trailing spaces from the value part, which can change strings like "left !important" or any value with significant spaces. Adjust the value extraction to only remove whitespace that is clearly structural around the colon/semicolon, without trimming the actual value content.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution as an educational override so you can keep progressing while you refine a few remaining details. Your parsing logic is solid: it correctly splits the style string, skips empty ; declarations, and preserves values like left !important without trimming away important whitespace. The main issue to address is naming: the accumulator stylesObject (see src/convertToObject.js, around the reduce call) still conflicts with [CHECKLIST ITEM #2], and sourceString is more generic than the domain-specific names requested in the instructions. To improve, rename these to something like stylesInput for the parameter and stylesByProperty (or similar) for the accumulator, so your code clearly expresses what the data represents instead of what type it is. Once you adjust these names, your implementation will not only meet the functional requirements but also align fully with the style and checklist expectations. Overall, you’re very close—your functional approach and handling of edge cases look great, and tightening the naming will make your code even clearer and more professional.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| .split(';') | ||
| .map((codeCss) => codeCss.trim()) | ||
| .filter((trimCodeCss) => trimCodeCss.includes(':')) | ||
| .reduce((stylesObject, currentLine) => { |
There was a problem hiding this comment.
This violates checklist item #2: "Avoid variable namings like array , object arr, obj, result. It will decrease code readability" – stylesObject still uses object in the name and should be renamed to a more domain-specific identifier (e.g., stylesByProperty).
No description provided.