Do I need to add a semicolon to the JS code?
Semicolons in Javascript separate communities. Some people like to use semicolons anyway. Others prefer not to include semicolons. After years of using semicolons, in the fall of 2017, I decided to try going without semicolons as needed, and set Prettier to automatically remove semicolons from my code unless necessary code structures required them. Now I find it very natural not to use semicolons, I think such codes look better, they are more concise and readable. This is entirely possible because Javascript does not strictly require semicolons. When a semicolon is required somewhere, it adds it behind the scenes. This process is called automatic semicolon insertion. It is important to understand the rules for using semicolons so that you can avoid writing buggy code because they behave as you expect s difference. Javascript automatically adds semicolon rules Javascript interpreter finds the following special circumstances when interpreting the source code, it will automatically add semicolons: When the beginning of the next line of code interrupts the current line of code (the code can be written in multiple lines) The next line starts with }, closing the current block When the end of the source code is reached When the return statement is…