From 267f069451846fe4ce6f5f258e7c20fa9fbce5a9 Mon Sep 17 00:00:00 2001 From: kaplunova Date: Wed, 13 Nov 2024 14:48:14 +0200 Subject: [PATCH] added func --- src/convertToObject.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/convertToObject.js b/src/convertToObject.js index 32c556ea4..62ccb3940 100644 --- a/src/convertToObject.js +++ b/src/convertToObject.js @@ -6,7 +6,16 @@ * @return {object} */ function convertToObject(sourceString) { - // write your code here + const arrayWithStyles = complexStylesString.split(';') + .map((el) => el.trim()); + const resultObject = {}; + + for (const el of arrayWithStyles) { + const pair = el.split(':').map((el) => el.trim()); + resultObject[pair[0]] = pair[1]; + } + + return resultObject; } module.exports = convertToObject;