Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Default Values | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
JavaScript Essentials for Beginners - 1768407374405

bookDefault Values

Note
Definition

Default values are values that are taken up by the parameters of a function when no corresponding argument is passed into the function call.

We can assign default values to parameters using the syntax:

function funcName(parameter1 = value1, parameter2 = value2, …) {
  // your code here …
}

Example:

12345
function sum(a = 5, b = 10) { return a + b; } console.log(sum()); // Output: 15
copy

1. What happens if a function parameter has a default value and no argument is passed for it in the function call?

2. What will be the output of the following code?

3. What will be the output of the following code?

question mark

What happens if a function parameter has a default value and no argument is passed for it in the function call?

Select the correct answer

question mark

What will be the output of the following code?

Select the correct answer

question mark

What will be the output of the following code?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 54

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

bookDefault Values

Pyyhkäise näyttääksesi valikon

Note
Definition

Default values are values that are taken up by the parameters of a function when no corresponding argument is passed into the function call.

We can assign default values to parameters using the syntax:

function funcName(parameter1 = value1, parameter2 = value2, …) {
  // your code here …
}

Example:

12345
function sum(a = 5, b = 10) { return a + b; } console.log(sum()); // Output: 15
copy

1. What happens if a function parameter has a default value and no argument is passed for it in the function call?

2. What will be the output of the following code?

3. What will be the output of the following code?

question mark

What happens if a function parameter has a default value and no argument is passed for it in the function call?

Select the correct answer

question mark

What will be the output of the following code?

Select the correct answer

question mark

What will be the output of the following code?

Select the correct answer

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 54
some-alt