-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #3751
base: master
Are you sure you want to change the base?
Solution #3751
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,19 @@ | |
* @return {object} | ||
*/ | ||
function convertToObject(sourceString) { | ||
// write your code here | ||
const sourceStringToArray = sourceString | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a critical issue here: the division operator |
||
.split(';') | ||
.map((item) => item.trim()) | ||
.filter((item) => item.length > 0); | ||
const sourceStringToObject = Object.fromEntries( | ||
sourceStringToArray.map((item) => { | ||
const [key, value] = item.split(':', 2); | ||
|
||
return [key.trim(), value.trim()]; | ||
}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an unnecessary comma at the end of this line. It should be removed to avoid syntax errors. |
||
); | ||
|
||
return sourceStringToObject; | ||
} | ||
|
||
module.exports = convertToObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a syntax error here. The division operator
/
is incorrectly used instead of the assignment operator=
. It should beconst sourceStringToArray = sourceString
.