-
Notifications
You must be signed in to change notification settings - Fork 2.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 #2700
base: master
Are you sure you want to change the base?
solution #2700
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.
Nice start! Let's fix and improve your work a little bit)
src/transformState.js
Outdated
break; | ||
|
||
case 'removeProperties': | ||
if (keysToRemove) { |
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.
Unnecessary condition. If 'keysToRemove' is not provided, the for...of loop will simply not run. Therefore, the if (keysToRemove) condition is redundant and can be removed.
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.
not fixed
src/transformState.js
Outdated
case 'removeProperties': | ||
if (keysToRemove) { | ||
for (const key of keysToRemove) { | ||
if (state.hasOwnProperty(key)) { |
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 hasOwnProperty check is not necessary when deleting a property. JavaScript will not throw an error if you try to delete a property that does not exist. Thus, this line can be safely removed.
src/transformState.js
Outdated
@@ -6,6 +6,36 @@ | |||
*/ | |||
function transformState(state, actions) { | |||
// write code here | |||
for (const action of actions) { | |||
const { type, extraData, keysToRemove } = action; |
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.
Inconsistent destructuring of 'action'. The task description mentions that the second property of the action object can vary depending on the type, but here you're destructuring 'extraData' and 'keysToRemove' regardless of the type. You should move the destructuring inside the corresponding case blocks.
src/transformState.js
Outdated
break; | ||
|
||
case 'removeProperties': | ||
if (keysToRemove) { |
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.
not fixed
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.
Perfect!!!
No description provided.