Skip to content
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

Solution #2572

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #2572

wants to merge 3 commits into from

Conversation

odolga
Copy link

@odolga odolga commented Jul 18, 2023

No description provided.

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job
But let's make your code perfect

@@ -5,7 +5,31 @@
* @param {Object[]} actions
*/
function transformState(state, actions) {
// write code here
for (const action of actions) {
const valueOfType = action['type'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name 'valueOfType' could be more descriptive. Consider renaming it to 'actionType' to better represent its content.

Comment on lines 8 to 9
for (const action of actions) {
const valueOfType = action['type'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a desctructurization here for action

Suggested change
for (const action of actions) {
const valueOfType = action['type'];
for (const action of actions) {
const {} = action;

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Keep doing


switch (type) {
case 'addProperties':
(Object.assign(state, action['extraData']));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(Object.assign(state, action['extraData']));
(Object.assign(state, action.extraData));

There is no need to use dynamic keys. Consider using static keys or using destructuring

break;

case 'removeProperties':
for (const keyToDelete of action['keysToRemove']) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous comment

Copy link

@anastasiiavorobiova anastasiiavorobiova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants