JAVASCRIPT EXAM WITH 100%
CORRECT ANSWERS
Which of the following is not a valid operator?
A. +=
B. ==
C. ++
D. =+
E. -- - Answer-D
What value is returned by 9 % 5? - Answer-4
What is the difference between == and === ?
A. The == operator only checks for equivalent values, not equivalent type too.
B. The == operator is the assignment operator, while === is the equality operator.
C. The === operator only checks for equivalent values, not equivalent type too. -
Answer-A
What is the logical operator for AND? - Answer-&&
JavaScript code must be placed in the <head> section of the document. ( T/F ) -
Answer-F
Which tag is used to let the browser know that it is about to see JavaScript code?
A. script
B. head
C. js - Answer-A
Which is the correct syntax to change the contents of the HTML element below?
<p id = "quiz">This is a quiz. </p>
A. document.getElementById('quiz').innerHTML ="New content!!";
B. #quiz.innerHTML="New content!!";
C. document.getElementsByTagName('p').innerHTML ="New content!!";
D. quiz.innerHTML="New content!"; - Answer-A
Where can you put JavaScript?
A) In the <head> section
B) In the <body> section
, C) In an external file
D) In B) and C) above
E) In A), B) and C) above - Answer-E
Which attribute is used to link to an external JavaScript file?
A. href; e.g., href = "extFile.js"
B. src; e.g., src = "extFile.js"
C. file; e.g., file = "extFile.js"
D. script; e.g., script = "extFile.js" - Answer-B
Which word is used to define a function in JavaScript?
A. function
B. func
C. define - Answer-A
Which of the following best defines the relationship between defining a function and
calling a function?
A. A function can be defined multiple times in a single file
B. A function can be called multiple times in a single file. - Answer-B
Every valid web page can be represented as a tree. This tree is referred to as the
A. JavaScript
B. API
C. DOM - Answer-C
JavaScript uses what kind of interface to access the DOM structure?
A. CSS3
B. an API
C. HTML5 - Answer-B
Which of these is not valid? (Hint, pay attention to if the method should return one thing,
or many things...)
A. document.getElementsByTagName(tagName)
B. document.getElementsByClassName(className)
C. document.getElementsById(idName) - Answer-C
Which of the following is not a valid method for generating output to the screen?
A. document.write
B. print
C. alert
D. prompt - Answer-B
Which of these options does NOT require the use of parentheses?
A. console.log
B. prompt
C. alert
CORRECT ANSWERS
Which of the following is not a valid operator?
A. +=
B. ==
C. ++
D. =+
E. -- - Answer-D
What value is returned by 9 % 5? - Answer-4
What is the difference between == and === ?
A. The == operator only checks for equivalent values, not equivalent type too.
B. The == operator is the assignment operator, while === is the equality operator.
C. The === operator only checks for equivalent values, not equivalent type too. -
Answer-A
What is the logical operator for AND? - Answer-&&
JavaScript code must be placed in the <head> section of the document. ( T/F ) -
Answer-F
Which tag is used to let the browser know that it is about to see JavaScript code?
A. script
B. head
C. js - Answer-A
Which is the correct syntax to change the contents of the HTML element below?
<p id = "quiz">This is a quiz. </p>
A. document.getElementById('quiz').innerHTML ="New content!!";
B. #quiz.innerHTML="New content!!";
C. document.getElementsByTagName('p').innerHTML ="New content!!";
D. quiz.innerHTML="New content!"; - Answer-A
Where can you put JavaScript?
A) In the <head> section
B) In the <body> section
, C) In an external file
D) In B) and C) above
E) In A), B) and C) above - Answer-E
Which attribute is used to link to an external JavaScript file?
A. href; e.g., href = "extFile.js"
B. src; e.g., src = "extFile.js"
C. file; e.g., file = "extFile.js"
D. script; e.g., script = "extFile.js" - Answer-B
Which word is used to define a function in JavaScript?
A. function
B. func
C. define - Answer-A
Which of the following best defines the relationship between defining a function and
calling a function?
A. A function can be defined multiple times in a single file
B. A function can be called multiple times in a single file. - Answer-B
Every valid web page can be represented as a tree. This tree is referred to as the
A. JavaScript
B. API
C. DOM - Answer-C
JavaScript uses what kind of interface to access the DOM structure?
A. CSS3
B. an API
C. HTML5 - Answer-B
Which of these is not valid? (Hint, pay attention to if the method should return one thing,
or many things...)
A. document.getElementsByTagName(tagName)
B. document.getElementsByClassName(className)
C. document.getElementsById(idName) - Answer-C
Which of the following is not a valid method for generating output to the screen?
A. document.write
B. print
C. alert
D. prompt - Answer-B
Which of these options does NOT require the use of parentheses?
A. console.log
B. prompt
C. alert