Guidelines for Programming with Functions

Some basic guidelines which every programmer must practice while writing a code with functions.

Creating functions wisely

Functions can include everything you can use in a regular program: variables, conditionals, loops, etc. Functions can call one another, giving the programmer an enormous amount of freedom for building programs. However, not everything deserves to be in its own function. It’s better to write short and focused ones, in order to limit dependencies and improve program understanding.

Leveraging JavaScript predefined functions

We have already used several predefined JavaScript functions like prompt() and alert(). There are many others in the language specification. Get to know them instead of reinventing the wheel! Here’s an example demonstrating two of the JavaScript mathematical functions.

Get hands-on with 1200+ tech skills courses.