diff --git a/src/convertToObject.js b/src/convertToObject.js index 32c556ea4..7b8c76672 100644 --- a/src/convertToObject.js +++ b/src/convertToObject.js @@ -6,7 +6,21 @@ * @return {object} */ function convertToObject(sourceString) { - // write your code here + const filteredArray = sourceString + .split(';') + .map((el) => el.trim()) + .filter(Boolean); + const styleObject = {}; + + for (const element of filteredArray) { + const [property, value] = element.split(':').map((part) => part.trim()); + + if (property && value) { + styleObject[property] = value; + } + } + + return styleObject; } module.exports = convertToObject;