Course says Hoisting isn't good practice, but then proceeds (in lesson 2/11) to force your to call the function before you've defined it

The title says it all,

I think the tasks in this lesson should be swapped so you are defining the function, THEN calling it.

No other language does hoisting as far as I can tell and while the lesson does say its bad practice, the lesson literally gets you to practice twice by doing it!

It’s not quite the same, but in C++ you can declare functions after your main function (you just need to outline the fact that it will be fleshed out later in the beginning). It’s quite normal practice, and since it’s a compiled language it doesn’t raise any issues.

1 Like

I believe the lesson does that so that you know how to do it, in case you wanted to. In some programs (for a example, a really long program embedded into HTML), you may wish to use JS’ hoisting ability by having all the functional code at the top, and then any helper functions below.