P3.3: JS Functions & Scope
Functions are blocks of reusable logic. Scope determines the accessibility of variables declared in the code.
Functions are blocks of reusable logic. Scope determines the accessibility of variables declared in the code.
Lesson: p3-3-functions
Functions are blocks of reusable logic. Scope determines the accessibility of variables declared in the code.
Functions are created using declarations or modern ES6 arrow expressions:
// Classic Declaration
function add(a, b) {
return a + b;
}
// ES6 Arrow Function (Prevalent in React)
const multiply = (a, b) => a * b;