Recall & Review
beginner
What are function parameters in JavaScript?
Function parameters are names listed in a function definition. They act like placeholders for values that the function will receive when called.
Click to reveal answer
beginner
How do you define a function with two parameters named
a and b?You write: <br><pre>function example(a, b) {<br> // code here<br>}</pre>Click to reveal answer
intermediate
What happens if you call a function with fewer arguments than parameters?
The missing parameters get the value
undefined. You can check for this inside the function to handle missing values.Click to reveal answer
intermediate
What is a default parameter value in JavaScript functions?
A default parameter value is a value assigned to a parameter in the function definition. It is used if no argument is passed for that parameter when the function is called.
Click to reveal answer
beginner
How do you write a function with a default parameter value of 10 for parameter
num?You write: <br><pre>function example(num = 10) {<br> // code here<br>}</pre>Click to reveal answer
What will be the value of
b when calling function test(a, b) {} as test(5)?✗ Incorrect
If you call a function with fewer arguments than parameters, the missing parameters get the value undefined.
How do you assign a default value of 100 to a parameter
x in a function?✗ Incorrect
The correct syntax for default parameters in JavaScript is
function f(x = 100) {}.Which of the following is true about function parameters?
✗ Incorrect
Parameters are names used inside function definitions to receive values when the function is called.
What happens if you call a function with more arguments than parameters?
✗ Incorrect
Extra arguments are ignored by named parameters but can be accessed using the
arguments object or rest parameters.Which keyword is used to collect multiple function arguments into an array?
✗ Incorrect
The rest parameter syntax
...name collects multiple arguments into an array.Explain what function parameters are and how they work in JavaScript.
Think about how functions get information to work with.
You got /3 concepts.
Describe how to use default parameter values and why they are useful.
Consider what happens when a function is called without some arguments.
You got /3 concepts.