diff --git a/src/convertToObject.js b/src/convertToObject.js index 32c556ea4..22d81e8a5 100644 --- a/src/convertToObject.js +++ b/src/convertToObject.js @@ -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;