Calling Functions
In the previous exercise, you may have noticed that when we define a function and run the code, nothing happens. That's because the function runs only when we call it. We call a function by its name followed by parentheses. For example, if we have a function defined as follows:
function myFunction() {
console.log("This is my function");
}
We can call it as follows:
myFunction(); // Prints: This is my function
When we call a function, its body is executed. In this case, This is my function
is printed. Functions can be called repeatedly and whenever needed within the program.
Instructions
Call the firstFunction
three times.
Start programming for free
3/7