Also called: return, parameters
Example
The function formatPrice turns 2500000 into "IDR 2,500,000".
In code
function total(nights, rate) {
return nights * rate;
}
Learn more
Related terms
Added 2026-11-30 · Last reviewed 2026-11-30
A named, reusable block of JavaScript code, written with the function keyword or as an arrow function.
Also called: return, parameters
The function formatPrice turns 2500000 into "IDR 2,500,000".
function total(nights, rate) {
return nights * rate;
}
Added 2026-11-30 · Last reviewed 2026-11-30