How to call a function in JavaScript?

To call a function in JavaScript, do this: myFunction().

Here's how you do it:

function myFunction() {
  console.log('Hello World!');
}

myFunction(); // Hello World!

Pass a parameter

Here's how you can pass a parameter to your function:

function myFunction(parameter) {
  console.log(parameter);
}

myFunction('Hello World!'); // Hello World!

Return a value

Here's how you can also return a value from your function:

function myFunction(parameter) {
  return parameter + 2;
}

const returnValue = myFunction(3);

console.log(returnValue); // 5