SamanAtashi / Best_To-Do-List

A simple one-page web app that stores and shows the tasks built with JavaScript and HTML/CSS.
1 stars 0 forks source link

JS_Best_Practices: #6

Open SamanAtashi opened 3 years ago

SamanAtashi commented 3 years ago

JS_Best_Practices:

  1. avoid global variables (specially mutable one's)
SamanAtashi commented 3 years ago

Avoid global variables (especially mutable one's)❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L7

SamanAtashi commented 3 years ago

Try to use strict comparison instead of == or != ❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L25-L28

same here:

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L173

SamanAtashi commented 3 years ago

Avoid unnecessary comments because it made your code ugly❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L29

SamanAtashi commented 3 years ago

instead of appendChild you can use Element.append() and put everything in one line ❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L47-L52

SamanAtashi commented 3 years ago

You used this function in a separate file(CRUD.js) but did not import it here and you repeated: ❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L54-L66

same happened here:❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L74-L84

SamanAtashi commented 3 years ago

if your variable is not gonna be re-assigned try using const:❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L100

SamanAtashi commented 3 years ago

Usually if you have an if condition alone in a block of code, it means that the condition can be separate on its own: ❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L155-L164

SamanAtashi commented 3 years ago

Try to come up with a solution to avoid repeating this amount of code : DRY please ❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L197-L242

same here: ❗️

https://github.com/SamanAtashi/Best_To-Do-List/blob/57a9b551c00942213963cee7d9a9208b60e8fdab/src/index.js#L244-L249