diff --git a/src/transformState.js b/src/transformState.js index a1eaa0640..5b2b8e988 100644 --- a/src/transformState.js +++ b/src/transformState.js @@ -5,7 +5,25 @@ * @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 keyToRemove of action.keysToRemove) { + delete state[keyToRemove]; + } + break; + case 'clear': + for (const key in state) { + delete state[key]; + } + break; + default: + break; + } + } } module.exports = transformState;