diff --git a/src/convertToObject.js b/src/convertToObject.js index 32c556ea4..9c49df5ad 100644 --- a/src/convertToObject.js +++ b/src/convertToObject.js @@ -6,7 +6,19 @@ * @return {object} */ function convertToObject(sourceString) { - // write your code here + const result = {}; + + sourceString + .split(';') + .map((line) => line.trim()) + .filter((line) => line !== '') + .forEach((line) => { + const [key, value] = line.split(':'); + + result[key.trim()] = value.trim(); + }); + + return result; } module.exports = convertToObject;