Back to course home
0% completed
Vote For New Content
Quiz
How do you define a function in JavaScript that calculates the sum of two numbers?
Choose all correct options
function sum(a + b) { return a + b; }
function sum(a, b) { return a + b; }
sum(a, b) => return a + b;
let sum = function(a, b) { return a + b; };
What is the default return value of a function in JavaScript that does not explicitly return a value?
A
null
B
0
C
undefined
D
false
How do you declare a function with default parameters in JavaScript?
Choose all correct options
function greet(name = "Guest") { console.log("Hello, " + name); }
function greet(name: "Guest") { console.log("Hello, " + name); }
function greet(name || "Guest") { console.log("Hello, " + name); }
let greet = function(name = "Guest") { console.log("Hello, " + name); };
What is output by the following arrow function in JavaScript?
let add = (a, b) => a + b;
console.log(add(5, 7));
A
12
B
7
C
undefined
D
Error
Which statement is true about variable scope within a JavaScript function?
A
Variables declared with var inside a function are global.
B
Variables declared with let inside a function can be accessed outside the function.
C
Variables declared with var inside a function are local to the function.
D
Variables declared with const inside a function are hoisted to the global scope.
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible