Recall & Review
beginner
What does the
return statement do in a JavaScript function?It stops the function and sends a value back to where the function was called.
Click to reveal answer
beginner
Can a JavaScript function return more than one value directly?
No, a function returns only one value. But you can return an object or array to hold multiple values.
Click to reveal answer
beginner
What happens if a function does not have a
return statement?The function returns
undefined by default.Click to reveal answer
beginner
How do you capture the value returned by a function?
You assign the function call to a variable, like <code>let result = myFunction();</code>Click to reveal answer
beginner
What is the difference between
console.log() and return in a function?console.log() shows output on the screen but does not send a value back. return sends a value back to the caller.Click to reveal answer
What does a
return statement do inside a function?✗ Incorrect
The
return statement stops the function and sends a value back to where it was called.What value does a function return if it has no
return statement?✗ Incorrect
Functions without a
return statement return undefined by default.How can you return multiple values from a function?
✗ Incorrect
You can return an array or object to hold multiple values from a function.
Which of these captures the returned value from a function?
✗ Incorrect
Assigning the function call to a variable captures the returned value.
What is the difference between
return and console.log()?✗ Incorrect
return sends a value back to the caller; console.log() only prints to the console.Explain what the
return statement does in a JavaScript function and why it is useful.Think about how functions give you answers.
You got /3 concepts.
Describe how you can return multiple values from a function in JavaScript.
Imagine putting things in a box to carry them all at once.
You got /3 concepts.