Skip to content

fixed#2735

Open
volodymyr-tytarenko wants to merge 2 commits intomate-academy:masterfrom
volodymyr-tytarenko:develop
Open

fixed#2735
volodymyr-tytarenko wants to merge 2 commits intomate-academy:masterfrom
volodymyr-tytarenko:develop

Conversation

@volodymyr-tytarenko
Copy link

No description provided.

Comment on lines +11 to +27
if (action.type === 'addProperties') {
Object.assign(state, action.extraData);
}

if (action.type === 'removeProperties') {
for (let i = 0; i < action.keysToRemove.length; i++) {
if (action.keysToRemove[i] in state) {
delete state[action.keysToRemove[i]];
}
}
}

if (action.type === 'clear') {
for (const value in state) {
delete state[value];
}
}

Choose a reason for hiding this comment

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

If you have predetermined amount of options it is better to use switch/case structure instead of multiple
if/else blocks

*/
function transformState(state, actions) {
// write code here
for (let key = 0; key < actions.length; key++) {

Choose a reason for hiding this comment

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

you can use for of here as far you don't need to know the index

}

if (action.type === 'removeProperties') {
for (let i = 0; i < action.keysToRemove.length; i++) {

Choose a reason for hiding this comment

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

usefor of

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.

2 participants