-
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
add task solution #3795
base: master
Are you sure you want to change the base?
add task solution #3795
Conversation
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.
Your implementation of the convertToObject
function is well done and meets the task requirements! 🎉 You've effectively used iteration methods like map
and filter
to transform the input string into a style object, and your approach aligns with the constraints provided. Keep up the great work, and continue honing your skills with these techniques! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@@ -6,7 +6,21 @@ | |||
* @return {object} | |||
*/ | |||
function convertToObject(sourceString) { | |||
// write your code here | |||
const filteredArray = sourceString |
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.
The initial split operation on the sourceString
is correct, as it divides the string into an array of style declarations based on semicolons.
const styleObject = {}; | ||
|
||
for (const element of filteredArray) { | ||
const [property, value] = element.split(':').map((part) => part.trim()); |
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.
The split operation on element
by colon is correct for separating property and value. However, note that handling multiple colons within a value is not required according to the additional prompt instructions.
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.
LGTM
No description provided.