Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #3791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #3791

wants to merge 1 commit into from

Conversation

DavidKuznets
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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


Your implementation of the convertToObject function is well-done and meets the task requirements effectively! 🎉 You've correctly utilized iteration methods and adhered to the constraints, ensuring a clean and functional solution. While there are some suggestions for handling edge cases, such as misplaced colons or ensuring unique property names, these are not critical to the core functionality. Keep up the great work, and consider these suggestions for further enhancing your code in future projects! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -6,7 +6,19 @@
* @return {object}
*/
function convertToObject(sourceString) {
// write your code here
return sourceString

Choose a reason for hiding this comment

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

The function starts by splitting the sourceString by semicolons, which is correct. However, ensure that the input string is not empty or null to avoid potential errors.

return sourceString
.split(';')
.map((style) => style.trim())
.filter((style) => style.includes(':'))

Choose a reason for hiding this comment

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

Filtering styles that include a colon is a good approach to ensure only valid declarations are processed. However, consider handling cases where the colon might be misplaced or there are multiple colons, even though it's not required by the task.

.split(':')
.map((item) => item.trim());

acc[property] = value;

Choose a reason for hiding this comment

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

Assigning the value to the property in the accumulator object is correct. Ensure that the property names are unique, as duplicate properties will overwrite previous values.

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