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

add solution #2749

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

add solution #2749

wants to merge 2 commits into from

Conversation

Misha408
Copy link

No description provided.

@@ -5,7 +5,29 @@
* @param {Object[]} actions
*/
function transformState(state, actions) {
// write code here
for (const obj of actions) {

Choose a reason for hiding this comment

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

use more meaningful variable names

Suggested change
for (const obj of actions) {
for (const action of actions) {

@@ -5,7 +5,29 @@
* @param {Object[]} actions
*/
function transformState(state, actions) {
// write code here
for (const obj of actions) {
if (obj.type === 'addProperties') {

Choose a reason for hiding this comment

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

it's better to use switch instead

Comment on lines 10 to 12
for (const i in obj.extraData) {
state[i] = obj.extraData[i];
}

Choose a reason for hiding this comment

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

Suggested change
for (const i in obj.extraData) {
state[i] = obj.extraData[i];
}
Object.assign(state, action.extraData);

break;

case 'removeProperties':
for (const i of action.keysToRemove) {

Choose a reason for hiding this comment

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

Suggested change
for (const i of action.keysToRemove) {
for (const key of action.keysToRemove) {

break;

case 'clear':
for (const i in state) {

Choose a reason for hiding this comment

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

Suggested change
for (const i in state) {
for (const key in state) {

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.

4 participants