-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 #3686
base: master
Are you sure you want to change the base?
Solution #3686
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the convertToObject
function! 🎉 Your code meets the task requirements and handles CSS style strings effectively. Just remember to trim both key
and value
to ensure no leading or trailing spaces sneak into your object. Keep up the great work! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
const [key, ...values] = el.split(':'); | ||
const value = values.join(':').trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of ...values
and values.join(':')
is correct for handling cases where the value itself might contain colons. However, ensure that the key
is properly trimmed before using it to avoid any leading or trailing spaces in the object keys.
if (key && value) { | ||
styles[key.trim()] = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that both key
and value
are trimmed before checking their truthiness. This will prevent any issues with keys or values that might have only whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work 👍
.map((el) => el.trim()) | ||
.filter((el) => el.includes(':')) | ||
.forEach((el) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- arr/array/str/string/el/elem/obj/object/res/result are bad names, name should describe variable
- You can use
reduce
to generate an object with it
No description provided.