-
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
Solved the task #2741
base: master
Are you sure you want to change the base?
Solved the task #2741
Conversation
src/transformState.js
Outdated
@@ -6,6 +6,25 @@ | |||
*/ | |||
function transformState(state, actions) { | |||
// write code here |
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.
Remove all comments
src/transformState.js
Outdated
for (const action of actions) { | ||
if (action.type === 'clear') { |
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.
- use object destructing for
action
- it'd much better to use
switch
case here instead ofif
- it is a good practice when you add a default behavior for
switch
statement. Yet, if you don't have such one - just throw an Error with text like "unexpected 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.
Almost done
src/transformState.js
Outdated
for (const action of actions) { | ||
const { type, extraData, keysToRemove } = action; | ||
|
||
switch (true) { |
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.
don't use true in switch statement. use type instead
src/transformState.js
Outdated
} | ||
|
||
default: | ||
return 'Unexpected acrion'; |
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.
return 'Unexpected acrion'; | |
return 'Unexpected 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.
Well done!
No description provided.