Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Yulii Zilnyk committed Jul 15, 2023
1 parent 8de408a commit 7130239
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/transformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@
* @param {Object[]} actions
*/
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':
for (const key of action.keysToRemove) {
delete state[key];
}
break;

case 'clear':
for (const key in state) {
delete state[key];
}
}
}
}

module.exports = transformState;

0 comments on commit 7130239

Please sign in to comment.