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

task solution #2747

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

task solution #2747

wants to merge 3 commits into from

Conversation

adrian200002
Copy link

No description provided.

const lines = sourceString.split(';');
const filteredLines = lines.filter(el => el.trim() !== '');

for (const css of filteredLines) {

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.

Copy link

@mosowiecka mosowiecka left a 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.

Copy link

@JoyCoffeeAddict JoyCoffeeAddict left a 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

Comment on lines 17 to 28
const cssProperties = {};

sourceString
.split(';')
.filter(el => el.trim() !== '')
.forEach(css => {
const [code, value] = css.split(':');

cssProperties[code.trim()] = value.trim();
});

return cssProperties;

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

Copy link

@mvjl000 mvjl000 left a comment

Choose a reason for hiding this comment

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

Great!

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.

4 participants