Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuxim committed Oct 16, 2024
1 parent 72716b5 commit bae75cd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/convertToObject.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
function convertToObject(sourceString) {
const styles = {};

sourceString
return sourceString
.split(';')
.filter(line => line.trim())
.forEach(line => {
.filter((line) => line.trim())
.reduce((acc, line) => {
const [property, value] = line.split(':');

if (property && value) {
const key = property.trim();
const val = value.trim();
styles[key] = val;
const trimmedProperty = property.trim();
const trimmedValue = value.trim();

acc[trimmedProperty] = trimmedValue;
}
});

return styles;
return acc;
}, {});
}

module.exports = convertToObject;

0 comments on commit bae75cd

Please sign in to comment.