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

Develop - Stateful clone #3903

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

Conversation

14lucas-mendes
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on addressing the major points in the checklist! 🌟 While there's a minor suggestion about renaming the 'copy' variable to something more descriptive like 'stateCopy', it doesn't significantly impact the functionality of your code. Keep up the good work, and consider more descriptive names in the future to enhance readability. 👍

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -8,6 +8,32 @@
*/
function transformStateWithClones(state, actions) {
// write code here

let copy = { ...state };

Choose a reason for hiding this comment

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

[NAMING] - The name 'copy' for the object that holds the current state is not descriptive enough. Consider using a more descriptive name like 'stateCopy' to improve code readability.

const story = [];

actions.forEach((action) => {
switch (action.type) {

Choose a reason for hiding this comment

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

[CODE STYLE]: Use a switch statement when you have a limited amount of conditions, which you have done correctly here.

});
break;

default:

Choose a reason for hiding this comment

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

[CODE STYLE]: The switch statement has a default case for error handling, which is good practice.

default:
break;
}
story.push({ ...copy });

Choose a reason for hiding this comment

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

It is better to push a copy of the object to the array at the end of each loop cycle, but outside of the switch block, after the current action is processed. This is done correctly here.

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