Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

implemented task #2828

wants to merge 3 commits into from

Conversation

ErnestMk1
Copy link

No description provided.

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a 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

Comment on lines 13 to 14
for (const object of actions) {
if (object.type === 'addProperties') {

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

@@ -7,7 +7,35 @@
* @return {Object[]}
*/
function transformStateWithClones(state, actions) {
// write code here
const stateClone = { ...state };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const stateClone = { ...state };
let stateClone = { ...state };

Comment on lines 29 to 32
case 'clear':
for (const key in stateClone) {
delete stateClone[key];
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case 'clear':
for (const key in stateClone) {
delete stateClone[key];
}
case 'clear':
stateClone = {};

Comment on lines 16 to 32
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];
}

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

@ErnestMk1 ErnestMk1 requested a review from etojeDenys October 5, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants