-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
implemented task #2828
base: master
Are you sure you want to change the base?
implemented task #2828
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 👍
Let's improve your code
src/transformStateWithClones.js
Outdated
for (const object of actions) { | ||
if (object.type === 'addProperties') { |
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 a destruction for object
and try to use a switch instead of if/else if
src/transformStateWithClones.js
Outdated
@@ -7,7 +7,35 @@ | |||
* @return {Object[]} | |||
*/ | |||
function transformStateWithClones(state, actions) { | |||
// write code here | |||
const stateClone = { ...state }; |
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.
const stateClone = { ...state }; | |
let stateClone = { ...state }; |
src/transformStateWithClones.js
Outdated
case 'clear': | ||
for (const key in stateClone) { | ||
delete stateClone[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.
case 'clear': | |
for (const key in stateClone) { | |
delete stateClone[key]; | |
} | |
case 'clear': | |
stateClone = {}; |
src/transformStateWithClones.js
Outdated
switch (type) { | ||
case 'addProperties': | ||
Object.assign(stateClone, extraData); | ||
|
||
stateVersions.push({ ...stateClone }); | ||
break; | ||
case 'removeProperties': | ||
for (const toRemove of keysToRemove) { | ||
delete stateClone[toRemove]; | ||
} | ||
|
||
stateVersions.push({ ...stateClone }); | ||
break; | ||
case 'clear': | ||
for (const key in stateClone) { | ||
delete stateClone[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.
we can push only one time at the end of the loop
No description provided.