diff --git a/src/transformState.js b/src/transformState.js index a1eaa064..28b41527 100644 --- a/src/transformState.js +++ b/src/transformState.js @@ -5,7 +5,27 @@ * @param {Object[]} actions */ function transformState(state, actions) { - // write code here + for (const action of actions) { + switch (action.type) { + case 'addProperties': + for (const key in action.extraData) { + state[key] = action.extraData[key]; + } + break; + + case 'removeProperties': + for (const key in action.keysToRemove) { + delete state[action.keysToRemove[key]]; + } + break; + + case 'clear': + for (const key in state) { + delete state[key]; + } + break; + } + } } module.exports = transformState;