Where this matters
Function parameters let a calculation use a caller’s value without needing to change the caller’s variable.
let total = 5;
function double(total) { return total * 2; }
console.log(double(total));
console.log(total);Read the full explanation
The parameter is a local binding initialized to five. Multiplication returns ten without assigning to the outer total.
Trace the code
- Calling double evaluates the outer total to 5 and initializes a separate local parameter with that number.
- The function returns 10. Returning a value does not assign that value to the outer total.
- The second log runs outside the function and reads the unchanged outer number.
Why the other predictions differ
5 5— The function does multiply its local parameter, so its return is ten.10 10— Returning a computed number does not assign it to the outer variable.
10 5
Reading this explanation does not record mastery. A correct submitted attempt can do so, including after review.
Change one thing
Explicitly assign the return value to total. Compare this with merely logging the return value.
Predict the result, then run this self-contained snippet in your browser’s developer console. It uses only sample values and makes no network requests.
let total = 5; function double(value) { return value * 2; } total = double(total); console.log(total);Check the variation’s output
10
Explain which binding, value, or operation changed before moving to the next challenge.