Hello guys this is my first post ever here. i recently joined codecademy Pro and started learning introduction to java script. Overall the course is awesome and the instant interactivity and projects makes learning more enjoyable , i have covered 80% of the course but at around the modules section i started facing an issue whenever the task would not complete i would look at my code and would waste a lot of time trying to find the issue even though i would know that my code was correct but whenever i would look for the hints issue would be that i was missing a semicolon most of the time , i know that java script doesn’t care for semicolons most of the time but it seems that it cares about semicolon sometime i will be happy to know when to put semicolons and when not to put semicolons perhaps some one should write a post about it as there is no whatsoever explanation given in the course. i apologize in advance if you do not understand my question as English is not my first language but i tried hard to make my concern clear to understand. thank you
Hello @mtea994!! Welcome to the forums!!
As such it is best practice to always place them at the end of a line of code, so as to prevent bugs.
I found this on MDN:
Though it does not give specific examples of bugs, it does show why you should use semicolons.
JS will attempt to correct for shoddy programming by inserting an implicit semi-colon where one ought to have been put by the programmer, according to a specific set of rules.
One such example of this behaviour is in this thread, alongside an explanation of the behaviour.
and thanks for replying
Count me in on that. IMO JS should just throw a syntax error here.