Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
return provides a value to the caller and ends the function. Logging displays information but does not replace returning a value. Without an explicit returned value, a normal function returns undefined.
function add(a, b) { return a + b; } lets the caller store or use the sum. function add(a, b) { console.log(a + b); } only logs the sum and its call evaluates to undefined. A bare return also returns undefined and stops execution. Code after an executed return in that function does not run.