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

JavaScript best practices : KISS #5

Open
redwing555 opened this issue Sep 27, 2021 · 1 comment
Open

JavaScript best practices : KISS #5

redwing555 opened this issue Sep 27, 2021 · 1 comment

Comments

@redwing555
Copy link
Owner

simplify these lines of code by giving the HTML element [...[...[...event.target.children][2].children][0].children][1] a descriptive variable name ex : trashcan , bin ... :

todo-list/src/crud.js

Lines 63 to 64 in ab9ced7

[...[...[...event.target.children][2].children][0].children][1].classList.remove('trash-active');
[...[...[...event.target.children][2].children][0].children][0].style.display = 'inline-block';

todo-list/src/crud.js

Lines 54 to 55 in ab9ced7

[...[...[...event.target.children][2].children][0].children][1].classList.add('trash-active');
[...[...[...event.target.children][2].children][0].children][0].style.display = 'none';

@redwing555
Copy link
Owner Author

use event instead of e and use taskDescription instead of desc here :

todo-list/src/index.js

Lines 69 to 72 in ab9ced7

list.addEventListener('click', (e) => {
const desc = [...e.target.children][1];
editTask(desc, tasks, e);
});

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