What's a Function? π οΈ
Next you'll write functions β little machines that take inputs and hand back an output. Let's read a few first so the shape feels familiar.
A function has a name, takes inputs in parentheses, and hands a value back
with the word return:
function double(n) {
return n * 2;
}
double(5); // 10
The value in the parentheses (5) becomes n inside the function. Without
return, a function hands back undefined β nothing useful.
Read each snippet below and predict the answer. π