Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
LX-y-ka committed Nov 13, 2024
1 parent a127773 commit d95d56a
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 @@ -7,6 +7,14 @@
*/
function convertToObject(sourceString) {
// write your code here
const mass = sourceString.split(';');
const result = mass.reduce((accumulator, a) => {
const styleElem = a.split(':').map((e) => e.trim());

return { ...accumulator, [styleElem[0]]: styleElem[1] };
}, {});

return result;
}

module.exports = convertToObject;

0 comments on commit d95d56a

Please sign in to comment.