-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add task solution #2617
base: master
Are you sure you want to change the base?
add task solution #2617
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it works nicely, BUT you should have taken a look at the checklist before approaching it ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there 🚀
src/transformState.js
Outdated
const ADD_PROPERTIES = order.type === 'addProperties'; | ||
const REMOVE_PROPERTIES = order.type === 'removeProperties'; | ||
const CLEAR_ALL = order.type === 'clear'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those should be constants outside of function - not depending on order.type
src/transformState.js
Outdated
if (ADD_PROPERTIES) { | ||
Object.assign(state, order.extraData); | ||
stateHistory.push(Object.assign({}, state)); | ||
} | ||
|
||
if (REMOVE_PROPERTIES) { | ||
for (const remove of order.keysToRemove) { | ||
delete state[remove]; | ||
} | ||
|
||
stateHistory.push(Object.assign({}, state)); | ||
} | ||
|
||
if (CLEAR_ALL) { | ||
for (const key in state) { | ||
delete state[key]; | ||
} | ||
|
||
stateHistory.push(Object.assign({}, state)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to checklist you should use switch statement
@@ -5,7 +5,36 @@ | |||
* @param {Object[]} actions | |||
*/ | |||
function transformState(state, actions) { | |||
// write code here | |||
const stateHistory = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you weren't prompted to track state history, but it's good idea 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so i keep this ;p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for any updates @MateuszSlezak 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job ✅
No description provided.