Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
maksym2493 committed Dec 15, 2024
1 parent a127773 commit d5ce2ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/convertToObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
* @return {object}
*/
function convertToObject(sourceString) {
// write your code here
return sourceString.split(';').reduce(addStyle, {});
}

function addStyle(styles, string) {
const style = string.split(':').map((item) => item.trim());

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

return styles;
}

module.exports = convertToObject;

0 comments on commit d5ce2ba

Please sign in to comment.