Why is there a semicolon after some functions in the Javascript course?

Up until https://www.codecademy.com/courses/introduction-to-javascript/lessons/functions/exercises/return, function statements don’t have semicolons in them.

But after that, they do.

Is this just to separate multiple function statements? I’ve read that you’re not supposed to include a semicolon after curly brackets {} in JS…

Semicolons are not always necessary in JS. I personally prefer to use semicolons whenever possible to provide clarity in my code and because many other languages do require the semicolon at the end of a statement. Here is a Codecademy post about it: Semicolons

1 Like

While including semicolons in your code is not required, they are automatically inserted as part of the parsing process by the interpreter. The rule of thumb that I prefer to follow is to be consistent in your code. Either place semicolons everywhere they should be, or only where they must be ie. for loops.

1 Like