-
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
task solution #2747
base: master
Are you sure you want to change the base?
task solution #2747
Conversation
src/convertToObject.js
Outdated
const lines = sourceString.split(';'); | ||
const filteredLines = lines.filter(el => el.trim() !== ''); | ||
|
||
for (const css of filteredLines) { |
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.
From checklist: Avoid using loops in this task, use iteration methods instead.
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.
Also, all chained methods called on the same level should have same indentation.
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.
Your code does work, but you can make it cleaner
src/convertToObject.js
Outdated
const cssProperties = {}; | ||
|
||
sourceString | ||
.split(';') | ||
.filter(el => el.trim() !== '') | ||
.forEach(css => { | ||
const [code, value] = css.split(':'); | ||
|
||
cssProperties[code.trim()] = value.trim(); | ||
}); | ||
|
||
return cssProperties; |
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.
That is great! But I believe that you can find a solution using Array.prototype.reduce
instead of forEach
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!
No description provided.