Skip to content

Commit

Permalink
develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaromanishyn committed Aug 7, 2023
1 parent 561c80c commit 0c829be
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
function transformState(state, actions) {
// write code here
for (const action of actions) {
const { type, extraData, keysToRemove } = action;
const { type } = action;

switch (type) {
case 'addProperties':
const { extraData } = action;

for (const key in extraData) {
state[key] = extraData[key];
}
break;

case 'removeProperties':
const { keysToRemove } = action;

if (keysToRemove) {
for (const key of keysToRemove) {
if (state.hasOwnProperty(key)) {
delete state[key];
}
delete state[key];
}
}
break;
Expand Down

0 comments on commit 0c829be

Please sign in to comment.