Functions can hand a value back
So far our functions have *done* things (drawn shapes). A function can also compute a value and hand it back with the return keyword. The returned value takes the place of the call, so you can store it in a variable.
function double(n) {
return n * 2;
}
let result = double(21); // result is now 42When the code hits return, the function stops and gives back that value. Here double(21) becomes 42, which we save in result.
Return vs. print
println *shows* a value; return *hands it back* so your program can keep using it. They're not the same — a returned value can be added, compared, or passed along.