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

Do I follow JavaScript best practices? #7

Closed
jonathastavares opened this issue Oct 4, 2021 · 1 comment
Closed

Do I follow JavaScript best practices? #7

jonathastavares opened this issue Oct 4, 2021 · 1 comment

Comments

@jonathastavares
Copy link
Owner

HTML and CSS looks Ok in my project.

*** list.js ***
static getDeleteButton(id) { const deletebtns = document.querySelectorAll('button[type=submit][id=delete-btn'); const deletebtn = deletebtns[id]; return deletebtn; }
Line 80 - getDeleteButton function is not being used, I can comment/remove this part of code. YAGNI

static completeItem(event) { const listArray = List.dataArray(); if (listArray[event.target.value - 1].completed === false) { listArray[event.target.value - 1].completed = true; localStorage.setItem('listArray', JSON.stringify(listArray)); } else { listArray[event.target.value - 1].completed = false; localStorage.setItem('listArray', JSON.stringify(listArray)); } }
Line 96 and Line 99 - Repeated same line inside both If's conditions, I could place this line after the IF statement and remove 1 line of the function, because this one will be executed independent of which IF condition are we in.

@jonathastavares
Copy link
Owner Author

Fixed all Issues!

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