russkiymalchik / code-refactoring-22-23

0 stars 0 forks source link

Redundant Check #2

Open russkiymalchik opened 1 year ago

russkiymalchik commented 1 year ago

This line of code redirects the user to the menu page if they already have a token saved in localstorage. However, the check for the token is redundant because if the token is not present in localStorage, localStorage.getItem('token') will return null which somehow false.

If I asked "Why could this flaw appear?: I probably would say because I generally more task-goal-oriented. so I did what I know without any consideration on the beauty of the code

localStorage.getItem('token') && (window.location.href = 'menu.html');
LidiaIvanova commented 1 year ago

It looks like bug, not code flaw.