diff --git a/src/transformState.js b/src/transformState.js index a1eaa064..36ac56c3 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) { + const { type } = action; + + if (type === 'addProperties') { + const { extraData } = action; + + Object.assign(state, extraData); + } else if (type === 'removeProperties') { + const { keysToRemove } = action; + + for (const key of keysToRemove) { + delete state[key]; + } + } else if (type === 'clear') { + for (const key in state) { + delete state[key]; + } + } + } } module.exports = transformState;