diff --git a/src/transformStateWithClones.js b/src/transformStateWithClones.js index 96d4f7e7e..1eee83981 100644 --- a/src/transformStateWithClones.js +++ b/src/transformStateWithClones.js @@ -7,7 +7,27 @@ * @return {Object[]} */ function transformStateWithClones(state, actions) { - // write code here + let stateClone = {...state}; + let actionHistory = []; + for (const action of actions) { + switch (action.type) { + case 'addProperties': + stateClone = {...stateClone,...action.extraData} + break; + case 'removeProperties': + action.keysToRemove.forEach(key => { + delete stateClone[key]; + }); + break; + case 'clear': + stateClone = {}; + + break; + default: + } + actionHistory.push({...stateClone}); + } + return actionHistory; } module.exports = transformStateWithClones;