Skip to content

Commit

Permalink
correct mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
maksym2493 committed Dec 15, 2024
1 parent d5ce2ba commit 4534522
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/convertToObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
* @return {object}
*/
function convertToObject(sourceString) {
if (!sourceString) {
return {};
}

return sourceString.split(';').reduce(addStyle, {});
}

function addStyle(styles, string) {
if (!string.includes(':')) {
return styles;
}

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

styles[style[0]] = style[1];
Expand Down

0 comments on commit 4534522

Please sign in to comment.