Name:
Class:
Date:
True / False
1. To retrieve data from or make changes to a web page element, you must first write code that identifies the specific
object you want to work with.
a.
True
b.
False
True
1
352
2. Method names are always followed by quotation marks.
a.
True
b.
False
False
1
352
3. The value property refers to the current value of a form field or an object property.
a.
True
b.
False
True
1
4. The addEventListener method is commonly used to access the element specified by a CSS selector.
a.
True
b.
False
False
1
353
5. Whenever you use a method, you specify its parent object first, followed by a space and then the method name.
a.
True
b.
False
False
1
354
6. You can use browser developer tools to enter test code and view error messages related to JavaScript.
a.
True
b.
False
True
1
354
Name:
Class:
Date:
7. The assignment operator is simply a question mark (?).
a.
True
b.
False
False
1
356
8. It’s common to store object references as variables.
a.
True
b.
False
True
1
358
9. JavaScript names can include spaces.
a.
True
b.
False
False
1
358
10. The contents of a function are executed automatically when they are parsed by a browser.
a.
True
b.
False
False
1
360
Modified True / False
11. You can think of the DOM as a hierarchical arrangement of the content of an HTML document into a tree-like
structure, which is known as a DOM root. _________________________
False – tree
1
352
12. In the DOM, each HTML element is considered a(n) property. _________________________
False – object
1
352
13. You can access any HTML element by specifying a CSS selector using the querySelector() method.
_________________________
True
Name:
Class:
Date:
14. A(n) property is a JavaScript instruction that performs an action. _________________________
False – statement
15. The script element is added to an HTML document to reference an external JavaScript file.
_________________________
16. To create a variable, you use the keyword create._________________________
17. To call a function in response to a user action, a developer creates a(n) object listener. _________________________
False – event
18. The submit event takes place when a user clicks or touches an element. _________________________
19. A common method for changing an element’s CSS styles in response to a user’s actions is to add or remove ID values
from the element in response to events. _________________________
20. JavaScript supports the use of symbols known as operators to compare or change the values of multiple objects or
properties._________________________
Multiple Choice
21. Writing code to look up and change data associated with parts of HTML documents requires a standardized way of
referring to the parts of a Web page; this system is known as the Document _________ Model.
Name:
Class:
Date:
a.
Element
b.
Object
c.
Property
d.
Method
b
1
352
22. Standard ____ for objects include the text content associated with an object, the name of the object, and the name of
an associated attribute.
a.
properties
b.
statements
c.
attributes
d.
values
1
352
23. The DOM defines ____, which are actions that are associated with an object.
a.
modes
b.
methods
c.
events
d.
activities
b
1
352
24. You can access any HTML element by specifying a CSS selector using the ____ method.
a.
querySelector()
b.
addEventListener()
c.
checkValidity()
d.
write()
1
352
25. The __________ property refers to the current value of a form field or an object property.
a.
classValue
b.
src
c.
textContent
d.
value
d
1
26. The __________ object is the parent element of the DOM tree.
a.
Document
b.
Element
c.
Head
d.
Body
1
354
27. Whenever you use a method, you specify its parent object first, followed by a(n) __________ and then the method
name.
Name:
Class:
Date:
a.
period
b.
comma
c.
semicolon
d.
hyphen
1
354
28. You specify a CSS selector in __________ within the parentheses of the querySelector() method to reference
an object.
a.
square brackets ( [ ] )
b.
curly braces ( { } )
c.
angle brackets ( < > )
d.
quotes ( ” ” )
d
1
354
29. The __________, which is part of the developer tools in a modern web browser, can be used to enter test code and
view error message related to JavaScript.
a.
address bar
b.
bookmarks list
c.
console
d.
emulator
1
354
30. Multi-line comments in JavaScript use the same format as __________ comments.
a.
WebVTT
b.
XHTML
c.
CSS
d.
HTML
1
354
31. A(n) __________ is a JavaScript instruction that performs an action.
a.
function
b.
event
c.
statement
d.
operator
1
356
32. To assign a new property value, you use the assignment operator, which is simply a(n) __________.
a.
equal sign ( = )
b.
plus sign ( + )
c.
less-than sign ( < )
d.
greater-than sign ( > )
1
356
33. Every JavaScript statement ends with a(n) __________.
Name:
Class:
Date:
a.
colon ( : )
b.
period ( . )
c.
semicolon ( ; )
d.
comma ( , )
1
356
34. JavaScript allows you to create __________, which are values that are stored and that you can access with a name that
you specify.
a.
events
b.
variables
c.
event listeners
d.
statements
b
1
358
35. The statement that creates a variable starts with the keyword __________.
a.
function
b.
var
c.
variable
d.
create
b
1
358
36. The first line of a function begins with the word function, followed by its name and a pair of ____.
a.
quotation marks
b.
parentheses
c.
equal signs
d.
exclamation marks
b
1
360
37. The punctuation for a function is similar to that of a CSS style rule: an opening ____ goes at the beginning.
a.
curly brace ({)
b.
bracket ([)
c.
quotation mark (“)
d.
pound sign (#)
1
360
38. Developers can write JavaScript that responds to actions, known as __________, which include many actions
commonly performed on a web page.
a.
methods
b.
activities
c.
events
d.
statements
1
362
39. The ____ event occurs when a user clicks or touches an element.
Name:
Class:
Date:
a.
click
b.
submit
c.
focus
d.
load
1
363
40. The ____ event occurs when a user moves the mouse pointer over an element or touches an element.
a.
submit
b.
mouseover
c.
mouseout
d.
load
b
1
363
41. To call a function in response to a user action, a developer creates a(n) __________.
a.
event listener
b.
variable
c.
event
d.
operator
1
362
42. A common method to change the CSS styles of an element in response to a user’s actions is to add or remove
__________ values from the element in response to events.
a.
ID
b.
form
c.
class
d.
CSS
1
364
43. JavaScript supports the use of symbols known as __________ to compare or change the values of multiple objects or
properties.
a.
statements
b.
functions
c.
operators
d.
variables
1
366
44. Using comparison operators, you can create a(n) __________ statement, in which two values are compared and if the
result is true, one or more statements are executed.
a.
if
b.
compare
c.
which
d.
for
1
366
Name:
Class:
Date:
45. Referring to the figure above, what is the role of the three lines of code labeled with the number 1?
a.
function call
b.
event listener
c.
function
d.
conditional statement
1
361
46. Referring to the figure above, what is the role of the line of code labeled with the number 2?
a.
function call
b.
event listener
c.
function
d.
conditional statement
1
361
47. Referring to the figure above, which of the following is a variable name used in the code shown?
a.
greetingText
b.
addGreeting
c.
Good Morning!
d.
function
1
361
48. Referring to the figure above, which of the following is a function name used in the code shown?
a.
greetingText
b.
addGreeting
c.
Good Morning!
d.
function
b
1
361
Name:
Class:
Date:
49. Referring to the figure above, what is the role of the line of code labeled with the number 1?
a.
It creates an event listener.
b.
It is a function.
c.
It creates a variable.
d.
It is a conditional statement.
1
363
50. Referring to the figure above, the word addEventListener is an example of a(n) __________.
a.
property
b.
variable
c.
method
d.
value
1
353, 362-363
51. Referring to the figure above, the code in this figure creates a(n) __________.
a.
function
b.
if statement
c.
variable
d.
event listener
b
1
366-367
52. Referring to the figure above, the code addressState.textContent === “CO” is a(n) __________.
a.
variable
b.
function
c.
expression
d.
event listener
Name:
Class:
Date:
367
53. Referring to the figure above, which of the following describes when the statements within the braces are executed?
a.
Only if the expression is true.
b.
Only if the expression is false.
c.
Whether the expression is true or false.
d.
Only in response to an event.
1
Case-Based Critical Thinking Question
Alicia wants to increase the sizes of images on her website in response to users moving the mouse pointer over them. To
add this feature, she plans to use JavaScript.
54. In Alicia’s JavaScript code, she can refer to a user moving the mouse pointer over an element with the __________
event.
a.
load
b.
mouseover
c.
mouseout
d.
submit
b
55. Alicia can create code that responds to an event using a(n) __________.
a.
variable
b.
if statement
c.
eventListener
d.
property
362
Critical Thinking
56. Alicia can change the CSS styles of the image with the mouse pointer over it by changing the element’s __________
property with JavaScript to add or remove class values from the element.
a.
elementName
b.
className
c.
value
d.
textContent
1
Critical Thinking
57. Alicia can create a set of statements to make the changes to her web page and reference the statements as a single unit
by creating a(n) __________.
a.
function
b.
variable
Name:
Class:
Date:
c.
event listener
d.
if statement
1
360
Critical Thinking
Case-Based Critical Thinking Question
Patrice is creating JavaScript code for her website. Her first task is to reference several HTML elements.
58. Patrice can reference HTML elements in JavaScript using the __________ method.
a.
selectElement
b.
selectId
c.
querySelector
d.
addEventListener
1
354
Critical Thinking
59. If Patrice follows common practice among JavaScript developers, she will store the HTML element references as
__________.
a.
functions
b.
variables
c.
event listeners
d.
properties
b
1
358
Critical Thinking
60. If Patrice wants to reference the content of an object and wants her code to work for users if IE8, she will
use the __________ property.
a.
textContent
b.
innerHTML
c.
src
d.
classValue
b
1
352
Completion
61. Each item in the DOM tree—including elements, attributes, and text content—is known as a(n) __________.
node
1
352
62. Each DOM node is associated with a standard set of information; each piece of information is known as a(n)
________________.
node
Name:
Class:
Date:
63. The querySelector() method is a child of the __________ object.
document
1
REFERENCES:
354
64. When creating a variable name that contains multiple words, it’s common to use __________ case.
camel
POINTS:
1
REFERENCES:
358
65. A function starts with the keyword __________.
ANSWER:
function
1
REFERENCES:
360
66. To execute the contents of a function, you must include a reference to the function name, known as a function
__________, elsewhere in your code.
ANSWER:
call
1
REFERENCES:
360
67. Using comparison operators, you can create a(n) __________ statement, in which two values are compared and if the
result is true, one or more statements are executed.
ANSWER:
1
REFERENCES:
366
Matching
Match each commonly used JavaScript property with the appropriate description.
a.
classValue
b.
innerHTML
c.
src
d.
textContent
e.
value
REFERENCES:
352
68. the path and source filename for an element with a src attribute
ANSWER:
1
1
REFERENCES:
352
Name:
Class:
Date:
69. the text content of an object, excluding any nested HTML tags
70. the current value of a form field or an object property
71. the content of an object, including any nested HTML tags
72. the value of an element’s class attribute
73. Explain the syntax of a statement that uses the assignment operator.
74. What kind of information can you store in a variable? How are variables useful when creating object references, and
why?
75. Name 3 ways that the punctuation for a function is similar to that of a CSS style rule.
Name:
Class:
Date: