JavaScript Quiz
Test your knowledge in
JavaScript
1. A function's default return value is:
a. null
b. undefined
c. no value
d. true
2. Which of the following is not a Math method?
a. Math.ceil()
b. Math.fround()
c. Math.abs()
d. Math.rand()
3. If a function declares a new local variable (using var) that has the same name as a global variable, the function uses
a. the global variable.
b. the local variable.
c. neither variable. It causes an error.
d. both the global and the local variable.
4. What purpose does myFunction serve here?
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World!";
}
a. It gets the element with class "demo" and changes the HTML content to "Hello World!"
b. It gets the element with ID "demo" and changes the HTML content to "Hello World!"
c. It gets the element with ID "demo" and changes the text content to "Hello World!"
d. It gets the element with ID "demo" and changes the ID to "Hello World!"
5. What does the following expression evaluate to?
var e = "fed";
/e{0,2}/.test(e);
a. true
b. false