Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
vladislav-tsybuliak1 committed Dec 27, 2024
1 parent a127773 commit 2a53001
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/convertToObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
* @return {object}
*/
function convertToObject(sourceString) {
// write your code here
const styles = sourceString.split(';');

return styles.reduce((prev, item) => {
if (item.trim()) {
let [key, val] = item.split(':');

key = key.trim();
val = val.trim();
prev[key] = val;
}

return prev;
}, {});
}

module.exports = convertToObject;

0 comments on commit 2a53001

Please sign in to comment.