-
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 #2572
base: master
Are you sure you want to change the base?
Solution #2572
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.
Good job
But let's make your code perfect
src/transformState.js
Outdated
@@ -5,7 +5,31 @@ | |||
* @param {Object[]} actions | |||
*/ | |||
function transformState(state, actions) { | |||
// write code here | |||
for (const action of actions) { | |||
const valueOfType = action['type']; |
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 name 'valueOfType' could be more descriptive. Consider renaming it to 'actionType' to better represent its content.
src/transformState.js
Outdated
for (const action of actions) { | ||
const valueOfType = action['type']; |
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.
You can use a desctructurization here for action
for (const action of actions) { | |
const valueOfType = action['type']; | |
for (const action of actions) { | |
const {} = 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.
Great work! Keep doing
src/transformState.js
Outdated
|
||
switch (type) { | ||
case 'addProperties': | ||
(Object.assign(state, action['extraData'])); |
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.
(Object.assign(state, action['extraData'])); | |
(Object.assign(state, action.extraData)); |
There is no need to use dynamic keys. Consider using static keys or using destructuring
src/transformState.js
Outdated
break; | ||
|
||
case 'removeProperties': | ||
for (const keyToDelete of action['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.
See my previous comment
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.
Great work
No description provided.