Skip to content

Commit

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

for (const str of strToArray) {
let [prop, value] = str.split(':');

if (prop && value) {
prop = prop.trim();
value = value.trim();
styles[prop] = value;
}
}

return styles;
}

module.exports = convertToObject;

0 comments on commit 0a741b4

Please sign in to comment.