Code Highlights logo

Learn

Functions

Calling a Function

To call a function, we need to use the function's name, followed by parentheses (). The parentheses are essential, as they indicate to the programming language that we want to execute the function.

Example:

1// Define a function that prints a greeting message
2function greet() {
3 console.log('Hello, welcome!');
4}
5
6// Call the greet function
7greet();

In the example above, we have defined a function greet() that prints a greeting message. By calling the greet() function, we execute the code within the function, and the message "Hello, welcome!" will be displayed in the console.


Instructions

1.

Call the greet function.
The function should print "Hello!" to the output.

Sign up to start coding

Already have an account?

Sign In

Course content