You did fine. Using the opening (
is not syntactically required in this context, but it makes a great warning to the human reader of the code about what is going on. The convention helps.
At the end, the invoking parens ()
can go inside, or outside, the closing )
. Doug Crawford recommends inside and many linters check for this. Despite his claims of dog balls1, it really doesn't matter.
By the way, the idea of function expression being declared and then immediately running is called an IFFE
-- Immediately Invoked Function Expression