Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
PavloMykhalov committed Jul 12, 2023
1 parent 8de408a commit b853630
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@
*/
function transformState(state, actions) {
// write code here
for (const action of actions) {
switch (action.type) {
case 'addProperties':
Object.assign(state, action.extraData);
break;

case 'removeProperties':
action.keysToRemove.forEach(key => delete state[key]);
break;

case 'clear':
Object.keys(state).forEach(key => delete state[key]);
break;

default:
break;
};
}

return state;
}

module.exports = transformState;

0 comments on commit b853630

Please sign in to comment.