Skip to content

solution#2737

Open
joanna-konopacka wants to merge 7 commits intomate-academy:masterfrom
joanna-konopacka:master
Open

solution#2737
joanna-konopacka wants to merge 7 commits intomate-academy:masterfrom
joanna-konopacka:master

Conversation

@joanna-konopacka
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@vlasiuksasha vlasiuksasha left a comment

Choose a reason for hiding this comment

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

check the comments

Comment thread src/transformState.js Outdated
break;

default:
return "Error: Type Unknown";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the 'default' case of your switch statement, you are returning a string. This will end the execution of the function, even if there are more valid actions in the 'actions' array. Instead, consider logging the error or ignoring the action with an invalid type.

Comment thread src/transformState.js Outdated
function transformState(state, actions) {
// write code here
for (const action of actions) {
const { type, extraData, keysToRemove } = action;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The destructuring of 'action' assumes that every action object has 'extraData' and 'keysToRemove' properties. This can potentially cause 'undefined' errors if these properties are absent. Consider destructuring these properties inside their respective case blocks.

Comment thread src/transformState.js
}
break;

case "clear":
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

However, there is a small issue with the "clear" case. When you want to clear all properties from the state object, using a for...in loop may not work as expected. Instead, you should use Object.keys to get an array of keys and then delete each key.

Copy link
Copy Markdown

@Ivan-Shvorak Ivan-Shvorak left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants