-
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 #3690
base: master
Are you sure you want to change the base?
solution #3690
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! 🎉 It meets all the task requirements and constraints, and your use of iteration methods instead of loops is spot on. Just make sure to define or pass stylesString
as an argument to avoid any runtime errors. Keep up the good work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
// write your code here | ||
const obj = {}; | ||
|
||
const stylesArray = stylesString |
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 variable stylesString
is used here but is not defined anywhere in the function. This will result in a ReferenceError. You need to ensure that stylesString
is defined or passed as an argument to the function.
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 job 👍
Left a few comments to improve your solution
const obj = {}; | ||
|
||
const stylesArray = stylesString |
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.
res/result/el/elem/arr/array/obj/object and etc are bad names, variable name should be descriptive
.map(style => style.trim()) | ||
.filter(style => style.length > 0); | ||
|
||
stylesArray.forEach(style => { |
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.
You can use reduce
to generate an object.
.filter(style => style.length > 0); | ||
|
||
stylesArray.forEach(style => { | ||
const [property, value] = style.split(':').map(item => item.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.
item
is not informative name as well
No description provided.