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

DRY principle #5

Open
Amedzro-Elikplim opened this issue Mar 2, 2022 · 2 comments
Open

DRY principle #5

Amedzro-Elikplim opened this issue Mar 2, 2022 · 2 comments

Comments

@Amedzro-Elikplim
Copy link
Owner

updateIndex = (index) => {
const num = index + 1;
for (let i = num; i < this.array.length; i += 1) {
this.array[i].index -= 1;
}
}

Change boring for loops into using forEach()

@Amedzro-Elikplim
Copy link
Owner Author

Minimalist/modules/Task.js

Lines 153 to 158 in 6d74fa0

const result = tasks.filter((item) => item.completed === true);
for (let i = 0; i < result.length; i += 1) {
this.delete(result[i].description);
}
}

Use forEach() in together with filter to make code readable

@Amedzro-Elikplim
Copy link
Owner Author

for (let i = 0; i < TODOS.length; i += 1) {
const task = TODOS[i];
const { description } = task;
const li = this.createList(description, i);
ul.appendChild(li);
}
};

avoid the use of boring for loops

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

No branches or pull requests

1 participant