Loading...

Quiz: JavaScript Functions

Research based quiz that cover function declarations, expressions, arrow functions, self-invoking functions, parameters, rest syntax, and more.

1.

What is the correct syntax for a function declaration in JavaScript?

2.

What will this code output?

javascript
4 lines
|
16/ 500 tokens
1
2
3
4
console.log(square(3));
function square(x) {
  return x * x;
}
Code Tools
3.

What is the output of the following code?

javascript
5 lines
|
18/ 500 tokens
1
2
3
4
5
const add = function(a, b) {
  return a + b;
};

console.log(add(2, 3));
Code Tools
4.

What is the output of this arrow function?

javascript
2 lines
|
16/ 500 tokens
1
2
const multiply = (a, b) => a * b;
console.log(multiply(3, 4));
Code Tools
5.

What will this code output?

javascript
5 lines
|
23/ 500 tokens
1
2
3
4
5
function greet(name = "Guest") {
  return "Hello, " + name + "!";
}

console.log(greet());
Code Tools