Guided Notes

Functions

Declarations, expressions, and arrow functions; parameters, defaults, and return; scope, hoisting, and closures.

Why functions?

Slide 1 / 5

A function is a reusable block of code with a name. Define it once, call it anywhere:

function toCelsius(fahrenheit) { return (fahrenheit - 32) * 5 / 9; } toCelsius(212) β†’ 100

Functions make code shorter, easier to test, and easier to change β€” fix the formula in one place and every caller benefits.

← Strings, Numbers & Math