Skip to content

Commit

Permalink
task done
Browse files Browse the repository at this point in the history
  • Loading branch information
gabai62 committed Dec 22, 2024
1 parent a127773 commit a2b66a9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/convertToObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit a2b66a9

Please sign in to comment.