Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman committed Dec 10, 2024
1 parent a127773 commit c68fa66
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/convertToObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
* @return {object}
*/
function convertToObject(sourceString) {
// write your code here
return Object.fromEntries(
sourceString
.split(';')
.map((declaration) => declaration.trim())
.filter(Boolean)
.map((declaration) => {
const [key, value] = declaration.split(':').map((part) => part.trim());

return [key, value];
}),
);
}

module.exports = convertToObject;

0 comments on commit c68fa66

Please sign in to comment.