Function Basics

Functions are blocks of reusable code. They help make your code modular, readable, and maintainable.

Defining a Function:

function greet() {
  console.log("Hello!");
}

Calling a Function:

greet(); // Output: Hello!

Functions can also return values:

function add(a, b) {
  return a + b;
}

console.log(add(3, 4)); // Output: 7
← PrevNext →