Thuta Learning
IntermediateProgrammingbeginner

JS Functions

Relax. We'll talk through this in plain words — no textbook voice.

Functions are blocks of code that only run when you call them. They can accept parameters and return a value.

javascript
// Function definition
function add(a, b) {
  return a + b;
}

// Calling the function
let sum = add(5, 7);
console.log("The sum is: " + sum);
You should see
The sum is: 12
JS Functions | Thuta Learning