hi there! ๐
-
There's a term in programming called modular programming. Basically, this means you should break down your programs into individual modules. And these modules very base are functions.
-
Modular programming have a lot of advantages: simplicity, reusability and scalability. With this in mind, the answer to your question: you should define functions everywhere possible.
-
Don't forget: you can use functions in
eventListeners
and conditional statements as well, making a function callback on global scope is not the only way to execute a function. ๐ โโ๏ธ
Hope this helped ๐
Good luck and happy coding! ๐ช
Marked as helpful