Professional Documents
Culture Documents
Final Exam Pool Questions
Final Exam Pool Questions
1) jQuery is
When taking the question, it would appear as:
jQuery is
Question options:
a programming language
a part of the CSS3 specification
an open-source JavaScript library
an extension of the Chrome browser
When grading the question, it would appear as:
jQuery is
a programming language
a part of the CSS3 specification
It allows you to get jQuery from another website and include it in your application.
It allows you to download jQuery and include it in your application.
It can only be used by the modern browsers.
It works even if you’re not connected to the Internet.
head element
body element
script element
link element
$ sign
quotation marks
parentheses
dot operator
$("#message").text()
$("#message").val()
$("#message").nodeValue()
$("#message").text()
$("#message").val()
$("#message").nodeValue()
$("#ship").text("Shipping is free.");
$("#ship").val("Shipping is free.");
$("#ship").nodeValue("Shipping is free.");
$("#ship").text("Shipping is free.");
$("#ship").val("Shipping is free.");
$("#ship").nodeValue("Shipping is free.");
When you use a single statement to call one method from another method.
selector
method
event method
selector
method
event method
script element
Question options:
Gets the h2 element that precedes the current element
Gets the element in the HTML that precedes the selected h2 element
Gets the previous sibling of each selected h2 element
Gets the previous sibling of each selected h2 element that is also an h2 element
When grading the question, it would appear as:
What does the following jQuery code do?
$("h2").prev();
Gets the previous sibling of each selected h2 element that is also an h2 element
Question options:
Gets the value of the src attribute for the element with an id of “image” and stores it in a variable named im
Sets the value of the src attribute for the element with an id of “image” to the value in a variable named ima
Gets the values of the src attribute for each element with a class of “image” and stores them in an array vari
Sets the values of the src attribute for each element with a class of “image” to the values in an array variable
When grading the question, it would appear as:
What does the following jQuery code do?
$("#image").attr("src", imageURL);
Gets the value of the src attribute for the element with an id of “image” and stores it in a
variable named imageURL
Sets the value of the src attribute for the element with an id of “image” to the value in a
variable named imageURL
Gets the values of the src attribute for each element with a class of “image” and stores
them in an array variable named imageURL
Sets the values of the src attribute for each element with a class of “image” to the values
in an array variable named imageURL
toggle()
toggleClass()
changeClass()
switchClass()
html()
hide()
every()
each()
click
mouseover
hover
all of the above
(Refer to code example 8-1) What does evt.currentTarget refer to in this code?
Question options:
The click() event method
The anonymous function for the click() event method
All h2 elements within the element with an id of “faqs”
The h2 element that was clicked
When grading the question, it would appear as:
Code example 8-1
$("#faqs h2").click( evt => {
const h2 = evt.currentTarget;
$(h2).toggleClass("minus");
if ($(h2).attr("class") !== "minus") {
$(h2).next().hide();
}
else {
$(h2).next().show();
}
evt.preventDefault();
});
(Refer to code example 8-1) What does evt.currentTarget refer to in this code?
The click() event method
The anonymous function for the click() event method
All h2 elements within the element with an id of “faqs”
(Refer to code example 8-1) Assuming none of the h2 elements include a class attribute when
the application starts, what happens the first time the user clicks on an h2 element?
Question options:
A class named “minus” is added to the element and the element’s next sibling is displayed.
A class named “minus” is added to the element and the element’s next sibling is hidden.
Nothing happens because the click() event method is used instead of the on() event method.
Nothing happens because the event object isn’t passed to the function for the event handler.
When grading the question, it would appear as:
Code example 8-1
$("#faqs h2").click( evt => {
const h2 = evt.currentTarget;
$(h2).toggleClass("minus");
if ($(h2).attr("class") !== "minus") {
$(h2).next().hide();
}
else {
$(h2).next().show();
}
evt.preventDefault();
});
(Refer to code example 8-1) Assuming none of the h2 elements include a class attribute when
the application starts, what happens the first time the user clicks on an h2 element?
A class named “minus” is added to the element and the element’s next sibling is
displayed.
A class named “minus” is added to the element and the element’s next sibling is hidden.
Nothing happens because the click() event method is used instead of the on() event
method.
Nothing happens because the event object isn’t passed to the function for the event
handler.
(Refer to code example 8-1) What does the parameter named evt refer to?
Question options:
the jQuery object
the Event object
the click() event method
the selector
When grading the question, it would appear as:
Code example 8-1
$("#faqs h2").click( evt => {
const h2 = evt.currentTarget;
$(h2).toggleClass("minus");
if ($(h2).attr("class") !== "minus") {
$(h2).next().hide();
}
else {
$(h2).next().show();
}
evt.preventDefault();
});
(Refer to code example 8-1) What does the parameter named evt refer to?
>
===
>=
!=
2) What are the values of the two variables when the following
code executes?let result1 = (1 == "1");let result2 = (1 ===
"1");
When taking the question, it would appear as:
What are the values of the two variables when the following code executes?
let result1 = (1 == "1");
let result2 = (1 === "1");
Question options:
both variables are true
both variables are false
result1 is false and result2 is true
result1 is true and result2 is false
When grading the question, it would appear as:
What are the values of the two variables when the following code executes?
let result1 = (1 == "1");
let result2 = (1 === "1");
Question options:
even numbers from 2 to 30
odd numbers from 1 to 29
an empty string
the number 1
When grading the question, it would appear as:
What is displayed when the following code executes?
let numbers = "";
for (let i = 1; i <= 30; i++) {
if( i % 2 === 0 ) {
continue;
} else {
numbers += i + " ";
}
}
alert(numbers);
any time
as long as the switch statement contains a default case
when several expressions are tested for equality with multiple values
Stop
Fall through to the default label
Throw an error
Question options:
OK
Forbidden
Not Found
Unknown Status
When grading the question, it would appear as:
What is displayed when the following code executes?
const statusCode = "403";
switch (statusCode) {
case "200":
alert("OK");
break;
case "403":
alert("Forbidden");
break;
case "404":
alert("Not Found");
break;
default:
alert("Unknown Status");
break;
}
OK
Forbidden
Not Found
Unknown Status
20
18
undefined
true
20
18
undefined
("Mike")
("")
(null)
("Mike")
("")
(null)
11) What does the following code display?let country = "";let
valid = "";if (country) { valid = "Valid";} else { valid =
"Not valid";}alert(valid);
When taking the question, it would appear as:
What does the following code display?
let country = "";
let valid = "";
if (country) {
valid = "Valid";
} else {
valid = "Not valid";
}
alert(valid);
Question options:
false
Valid
Not valid
empty string
When grading the question, it would appear as:
What does the following code display?
let country = "";
let valid = "";
if (country) {
valid = "Valid";
} else {
valid = "Not valid";
}
alert(valid);
false
Valid
Not valid
empty string
are unreliable
can only return Boolean values
14) Which line of code below provides a default value for the
variable named selected if the variable named state is null?
When taking the question, it would appear as:
Which line of code below provides a default value for the variable named selected if the
variable named state is null?
Question options:
let selected;
Question options:
It displays “Using geolocation”.
It displays “Not using geolocation”.
It displays an empty string.
It throws an error.
When grading the question, it would appear as:
If the geolocation property exists, what does the following code do?
let message = "";
if (window?.navigator?.geolocation) {
message = "Using geolocation";
} else {
message = "Not using geolocation";
}
alert(message);
name
type
value
message
The try block contains the code that may throw exceptions.
The catch block contains the code that is run when an exception is thrown.
The finally block contains code that runs whether or not an exception is thrown.
Create a new Error object and use the throw statement to throw it.
try {
const result = divide(10, 0);
alert(result);
}
catch(error) {
alert(error.name + " - " + error.message);
};
Question options:
You may not divide by zero.
Error - You may not divide by zero.
0
infinity
When grading the question, it would appear as:
What is displayed when the following code executes?
function divide(a, b) {
if (b === 0) {
throw new Error("You may not divide by zero.");
} else {
return a / b;
}
}
try {
const result = divide(10, 0);
alert(result);
}
catch(error) {
alert(error.name + " - " + error.message);
};
0
infinity
String
RegExp
Match
Pattern
24) Which method of a regular expression searches a string
and returns true if the pattern is found?
When taking the question, it would appear as:
Which method of a regular expression searches a string and returns true if the pattern is
found?
Question options:
test()
match()
find()
search()
When grading the question, it would appear as:
Which method of a regular expression searches a string and returns true if the pattern is
found?
test()
match()
find()
search()
c
g
i
x
26) Which of the following is used in a regular expression
pattern to match the beginning of a string?
When taking the question, it would appear as:
Which of the following is used in a regular expression pattern to match the beginning of a
string?
Question options:
$
-
27) Which of the following is used in a regular expression
pattern as an escape character?
When taking the question, it would appear as:
Which of the following is used in a regular expression pattern as an escape character?
Question options:
\
/+\d[5]?/
/^\d{5}$/
/$\d5^/
/+\d[5]?/
/^\d{5}$/
/$\d5^/
Question options:
"2/4/68"
"2-4-1968"
"02/04/68"
"2/4/1968"
When grading the question, it would appear as:
Which of the strings matches the following pattern?
/^[01]?\d\/[0-3]\d\/\d{4}$/
"2/4/68"
"2-4-1968"
"02/04/68"
"2/4/1968"
Question options:
Valid1
Valid2
Valid3
NOT Valid
When grading the question, it would appear as:
The following code displays
const text = "A111-B222-C333";
if (/^\d{4}-\d{4}-\d{4}-\d{4}$/.test(text)) {
alert("Valid1");
} else if (/^\d{4}-\d{4}-\d{4}$/.test(text)) {
alert("Valid2");
} else if (/^\w\d{3}-\w\d{3}-\w\d{3}$/.test(text)) {
alert("Valid3");
} else {
alert("NOT Valid");
}
Valid1
Valid2
Valid3
NOT Valid
It indicates the type of data the user should enter in the control.
It indicates the type of control the browser should display to the user.
It makes working with CSS easier.
autofocus
action
placeholder
pattern
autofocus
action
placeholder
valid fields
invalid fields
required fields
optional fields
val()
trim()
text()
select()
6) Which of the following is NOT a jQuery selector for
working with forms and controls?
When taking the question, it would appear as:
Which of the following is NOT a jQuery selector for working with forms and controls?
Question options:
:hidden
:disabled
:text
:submit
When grading the question, it would appear as:
Which of the following is NOT a jQuery selector for working with forms and controls?
:hidden
:disabled
:text
:submit
7) The jQuery features for forms and controls let you do all
but one of the following. Which one is it?
When taking the question, it would appear as:
The jQuery features for forms and controls let you do all but one of the following. Which one
is it?
Question options:
set the values of error messages
get the value in a text box
select the check boxes that are checked
validate specific types of entries in text boxes
When grading the question, it would appear as:
The jQuery features for forms and controls let you do all but one of the following. Which one
is it?
regular button
radio button
submit button
link
Within the click() event handler of a regular button, validate the data and then issue the
submit() method of the form if the data is valid.
Within the click() event handler of a regular button, validate the data and then issue the
reset() method of the form if the data is invalid.
Within the click() event handler of a submit button, validate the data and then issue the
preventDefault() method of the form if the data is valid.
Within the click() event handler of a submit button, validate the data and then issue the
reset() method of the form if the data is valid.
(Refer to code example 10-1) What do the jQuery selectors in this code select?
Question options:
an individual element by id only
all radio buttons only
an individual element by id and all radio buttons
an individual element by id and disabled radio buttons
When grading the question, it would appear as:
Code example 10-1
$(document).ready( () => {
$("#contact_me").change( () => {
if ($("#contact_me").attr("checked")) {
$(":radio").attr("disabled", false);
} else {
$(":radio").attr("disabled", true);
}
});
});
(Refer to code example 10-1) What do the jQuery selectors in this code select?
(Refer to code example 10-2) What does the preventDefault() method in this code do?
Question options:
It cancels the change event of the form.
It cancels the submit event of the form.
It triggers the change event of the form.
It triggers the submit event of the form.
When grading the question, it would appear as:
Code example 10-2
$(document).ready( () => {
$("#member_form").submit( event => {
let isValid = true;
...
const password = $("#password").val().trim();
if (password == "") {
$("#password").next().text("This field is required.");
isValid = false;
} else if ( password.length < 6) {
$("#password").next().text("Must be 6 or more characters.");
isValid = false;
} else {
$("#password").next().text("");
}
$("#password").val(password);
...
if (isValid == false) {
event.preventDefault();
}
});
});
(Refer to code example 10-2) What does the preventDefault() method in this code do?
(Refer to code example 10-2) Why is the following line of code necessary after the if-else
statement?
$("#password").val(password);
Question options:
The val() method removes the password entered by the user, so this code displays the original password.
The next() method replaces the password entered by the user, so this code displays the original password.
The text() method replaces the password entered by the user, so this code displays the original password.
The trim() method removes extra spaces entered by the user, so this code displays the trimmed password.
When grading the question, it would appear as:
Code example 10-2
$(document).ready( () => {
$("#member_form").submit( event => {
let isValid = true;
...
const password = $("#password").val().trim();
if (password == "") {
$("#password").next().text("This field is required.");
isValid = false;
} else if ( password.length < 6) {
$("#password").next().text("Must be 6 or more characters.");
isValid = false;
} else {
$("#password").next().text("");
}
$("#password").val(password);
...
if (isValid == false) {
event.preventDefault();
}
});
});
(Refer to code example 10-2) Why is the following line of code necessary after the if-else
statement?
$("#password").val(password);
The val() method removes the password entered by the user, so this code displays the
original password.
The next() method replaces the password entered by the user, so this code displays the
original password.
The text() method replaces the password entered by the user, so this code displays the
original password.
The trim() method removes extra spaces entered by the user, so this code displays the
trimmed password.
focus()
change()
leave()
select()
15) In the following code, what does the line of code in the
else clause do?$(document).ready( () => { $
("#join_list").click( () => { // join_list is a regular button
if ( $("email_address").val() == "") {  
When taking the question, it would appear as:
In the following code, what does the line of code in the else clause do?
$(document).ready( () => {
$("#join_list").click( () => { // join_list is a regular button
if ( $("email_address").val() == "") {
alert("Please enter an email address.");
} else {
$("#email_form").submit();
}
});
});
Question options:
It handles the submit event of the form with an id of “email_form”.
It triggers the submit event of the form with an id of “email_form”.
It handles the click event of the button with an id of “join_list”.
It triggers the click event of the button with an id of “join_list”.
When grading the question, it would appear as:
In the following code, what does the line of code in the else clause do?
$(document).ready( () => {
$("#join_list").click( () => { // join_list is a regular button
if ( $("email_address").val() == "") {
alert("Please enter an email address.");
} else {
$("#email_form").submit();
}
});
});
MIN_VALUE
MAX_VALUE
POSITIVE_INFINITY
NEGATIVE_INFINITY
NaN
-NaN
Infinity
-Infinity
12) What method of the Date object gets the day of the month?
When taking the question, it would appear as:
What method of the Date object gets the day of the month?
Question options:
the getMonth() method
the getDate() method
the getDay() method
the getDayOfMonth() method
When grading the question, it would appear as:
What method of the Date object gets the day of the month?
An integer value for the month, starting with 1 for January, 2 for February, etc.
An integer value for the month, starting with 0 for January, 1 for February, etc.
Question options:
NaN
53.937
53.94
53.93
When grading the question, it would appear as:
What is the value of salesTax after the following code executes?
let salesTax = 53.937;
salesTax = parseFloat(salesTax.toFixed(2));
NaN
53.937
53.94
53.93
text1 == text2
text1.toLowerCase() = text2.toLowerCase()
text1.toLowerCase() == text2.toLowerCase()
text1 == text2
text1.toLowerCase() = text2.toLowerCase()
text1.toLowerCase() == text2.toLowerCase()
due_date.setMonth(2);
due_date.setMonth("Feb");
due_date.setMonth("February");
due_date.setMonth(1);
due_date.setMonth(2);
due_date.setMonth("Feb");
due_date.setMonth("February");
17) What text does the following code display in the dialog
box?const investment = "$100";if (isNaN(investment) ||
investment <= 0) { alert("Investment is not valid.");} else
{ alert("Investment: " + investment.toFixed(2));
When taking the question, it would appear as:
What text does the following code display in the dialog box?
const investment = "$100";
if (isNaN(investment) || investment <= 0) {
alert("Investment is not valid.");
} else {
alert("Investment: " + investment.toFixed(2));
}
Question options:
Investment is not valid.
Investment: $100
Investment: $100.00
Investment: 100.00
When grading the question, it would appear as:
What text does the following code display in the dialog box?
const investment = "$100";
if (isNaN(investment) || investment <= 0) {
alert("Investment is not valid.");
} else {
alert("Investment: " + investment.toFixed(2));
}
Investment: $100
Investment: $100.00
Investment: 100.00
Question options:
An integer between 0 and 9
An integer between 0 and 10
An integer between 1 and 9
An integer between 1 and 10
When grading the question, it would appear as:
What is the value of random after the following code executes?
let random = Math.floor(Math.random() * 10);
Question options:
dueDate = dueDate + 21;
dueDate.setDate(21);
dueDate.setDate(dueDate.getDate() + 21);
dueDate.setDate(21);
dueDate.setDate(dueDate.getDate() + 21);
20) How can you calculate the number of days between the
dates in the two variables below?let taxDay = new
Date("4/15/2017");let xmas = new Date("12/25/2017");
When taking the question, it would appear as:
How can you calculate the number of days between the dates in the two variables below?
let taxDay = new Date("4/15/2017");
let xmas = new Date("12/25/2017");
Question options:
Subtract taxDay.getDate() from xmas.getDate().
Subtract taxDay.getDay() from xmas.getDay().
Subtract taxDay.getTime() from xmas.getTime() and divide by 86400000 to convert milliseconds to days.
Subtract taxDay from xmas.
When grading the question, it would appear as:
How can you calculate the number of days between the dates in the two variables below?
let taxDay = new Date("4/15/2017");
let xmas = new Date("12/25/2017");
Question options:
const us = new Intl.NumberFormat("en-US");
const totalStr = us.format(total);
const us = new Intl.NumberFormat("en-US",
{style:"currency", currency:"USD"});
const totalStr = us.format(total);
const us = new Intl.NumberFormat("en-EUR");
const totalStr = us.format(total);
>
===
>=
!=
2) What are the values of the two variables when the following
code executes?let result1 = (1 == "1");let result2 = (1 ===
"1");
When taking the question, it would appear as:
What are the values of the two variables when the following code executes?
let result1 = (1 == "1");
let result2 = (1 === "1");
Question options:
both variables are true
both variables are false
result1 is false and result2 is true
result1 is true and result2 is false
When grading the question, it would appear as:
What are the values of the two variables when the following code executes?
let result1 = (1 == "1");
let result2 = (1 === "1");
Question options:
even numbers from 2 to 30
odd numbers from 1 to 29
an empty string
the number 1
When grading the question, it would appear as:
What is displayed when the following code executes?
let numbers = "";
for (let i = 1; i <= 30; i++) {
if( i % 2 === 0 ) {
continue;
} else {
numbers += i + " ";
}
}
alert(numbers);
an empty string
the number 1
any time
as long as the switch statement contains a default case
when several expressions are tested for equality with multiple values
Stop
Fall through to the default label
Throw an error
7) What is displayed when the following code executes?const
statusCode = "403";switch (statusCode) { case "200":
alert("OK"); break; case "403": &nbs
When taking the question, it would appear as:
What is displayed when the following code executes?
const statusCode = "403";
switch (statusCode) {
case "200":
alert("OK");
break;
case "403":
alert("Forbidden");
break;
case "404":
alert("Not Found");
break;
default:
alert("Unknown Status");
break;
}
Question options:
OK
Forbidden
Not Found
Unknown Status
When grading the question, it would appear as:
What is displayed when the following code executes?
const statusCode = "403";
switch (statusCode) {
case "200":
alert("OK");
break;
case "403":
alert("Forbidden");
break;
case "404":
alert("Not Found");
break;
default:
alert("Unknown Status");
break;
}
OK
Forbidden
Not Found
Unknown Status
Question options:
true
20
18
undefined
true
20
18
undefined
("Mike")
("")
(null)
("Mike")
("")
(null)
Question options:
false
Valid
Not valid
empty string
When grading the question, it would appear as:
What does the following code display?
let country = "";
let valid = "";
if (country) {
valid = "Valid";
} else {
valid = "Not valid";
}
alert(valid);
false
Valid
Not valid
empty string
are unreliable
can only return Boolean values
14) Which line of code below provides a default value for the
variable named selected if the variable named state is null?
When taking the question, it would appear as:
Which line of code below provides a default value for the variable named selected if the
variable named state is null?
Question options:
let selected;
Question options:
It displays “Using geolocation”.
It displays “Not using geolocation”.
It displays an empty string.
It throws an error.
When grading the question, it would appear as:
If the geolocation property exists, what does the following code do?
let message = "";
if (window?.navigator?.geolocation) {
message = "Using geolocation";
} else {
message = "Not using geolocation";
}
alert(message);
name
type
value
message
The try block contains the code that may throw exceptions.
The catch block contains the code that is run when an exception is thrown.
The finally block contains code that runs whether or not an exception is thrown.
Create a new Error object and use the throw statement to throw it.
try {
const result = divide(10, 0);
alert(result);
}
catch(error) {
alert(error.name + " - " + error.message);
};
Question options:
You may not divide by zero.
Error - You may not divide by zero.
0
infinity
When grading the question, it would appear as:
What is displayed when the following code executes?
function divide(a, b) {
if (b === 0) {
throw new Error("You may not divide by zero.");
} else {
return a / b;
}
}
try {
const result = divide(10, 0);
alert(result);
}
catch(error) {
alert(error.name + " - " + error.message);
};
0
infinity
String
RegExp
Match
Pattern
test()
match()
find()
search()
25) Which letter is used to a create a flag for a case-insensitive
regular expression?
When taking the question, it would appear as:
Which letter is used to a create a flag for a case-insensitive regular expression?
Question options:
c
g
i
x
When grading the question, it would appear as:
Which letter is used to a create a flag for a case-insensitive regular expression?
c
g
?
*
/+\d[5]?/
/^\d{5}$/
/$\d5^/
/+\d[5]?/
/^\d{5}$/
/$\d5^/
Question options:
"2/4/68"
"2-4-1968"
"02/04/68"
"2/4/1968"
"2/4/68"
"2-4-1968"
"02/04/68"
"2/4/1968"
Question options:
Valid1
Valid2
Valid3
NOT Valid
When grading the question, it would appear as:
The following code displays
const text = "A111-B222-C333";
if (/^\d{4}-\d{4}-\d{4}-\d{4}$/.test(text)) {
alert("Valid1");
} else if (/^\d{4}-\d{4}-\d{4}$/.test(text)) {
alert("Valid2");
} else if (/^\w\d{3}-\w\d{3}-\w\d{3}$/.test(text)) {
alert("Valid3");
} else {
alert("NOT Valid");
}
Valid1
Valid2
Valid3
NOT Valid
search
query
params
options
path
host
hostname
href
location.replace("https://wwww.murach.com");
history.replace("https://wwww.murach.com");
history.go("https://wwww.murach.com");
location.replace("https://wwww.murach.com");
history.replace("https://wwww.murach.com");
history.go("https://wwww.murach.com");
replace()
back()
forward()
go()
history.go(1);
history.back();
history.go("back");
history.go(1);
history.back();
history.go("back");
7) Session cookies
When taking the question, it would appear as:
Session cookies
Question options:
must not have a path
are deleted when the browser is closed
are always encrypted when sent to the web server
are stored on the hard drive
When grading the question, it would appear as:
Session cookies
max-age
path
domain
secure
9) The max-age attribute of a cookie is specified in
When taking the question, it would appear as:
The max-age attribute of a cookie is specified in
Question options:
days
hours
seconds
milliseconds
When grading the question, it would appear as:
The max-age attribute of a cookie is specified in
days
hours
seconds
milliseconds
a space
a number
a comma
a semicolon
11) Code example 14-1let cookie =
"username=mike2009";cookie += "; max-age=" + 365 * 24 *
60 * 60;cookie += "; path=/";document.cookie = cookie;
(Refer to code example 14-1.) This code
When taking the question, it would appear as:
Code example 14-1
let cookie = "username=mike2009";
cookie += "; max-age=" + 365 * 24 * 60 * 60;
cookie += "; path=/";
document.cookie = cookie;
creates a cookie that’s removed when the user closes the browser
arrays
strings
key/value pairs
session
The data in web storage is passed to the server with every HTTP request.
session storage is lost when the browser closes; local storage is stored indefinitely
session storage is stored indefinitely; local storage is lost when the browser closes
session storage has a shortcut syntax and local storage doesn’t
local storage has a clear() method and session storage doesn’t
Question options:
localStorage.setItem("name", "Grace");
localStorage.getItem("name", "Grace");
localStorage.save("name", "Grace");
localStorage.clear("name", "Grace");
localStorage.setItem("name", "Grace");
localStorage.getItem("name", "Grace");
localStorage.save("name", "Grace");
localStorage.clear("name", "Grace");
sessionStorage.save(favoriteTeam, "Seahawks");
localStorage.favoriteTeam = "Seahawks";
localStorage.save(favoriteTeam, "Seahawks");
sessionStorage.save(favoriteTeam, "Seahawks");
localStorage.favoriteTeam = "Seahawks";
localStorage.save(favoriteTeam, "Seahawks");
undefined
1
undefined
an array
an element in an array
A for loop processes undefined elements, but a for-in loop skips over them.
Question options:
0|1|2|3|
0|1|undefined|3|
Dog|Cat|Bird|
Dog|Cat|undefined|Bird|
When grading the question, it would appear as:
What does the following code display?
const pets = ["Dog", "Cat", undefined, "Bird"];
let message = ""
for (const pet of pets) {
message += pet + "|";
}
alert(message);
0|1|2|3|
0|1|undefined|3|
Dog|Cat|Bird|
Dog|Cat|undefined|Bird|
Question options:
Dog
Cat
undefined
Bird
Dog
Cat
undefined
Bird
7) Which method adds one or more elements to the beginning
of an array?
When taking the question, it would appear as:
Which method adds one or more elements to the beginning of an array?
Question options:
shift()
unshift()
push()
pop()
When grading the question, it would appear as:
Which method adds one or more elements to the beginning of an array?
shift()
unshift()
push()
pop()
shift()
unshift()
push()
pop()
9) Which method returns the elements of an array in a string
where each element is separated by a comma?
When taking the question, it would appear as:
Which method returns the elements of an array in a string where each element is separated by
a comma?
Question options:
join()
concat()
splice()
shift()
When grading the question, it would appear as:
Which method returns the elements of an array in a string where each element is separated by
a comma?
join()
concat()
splice()
shift()
reduce()
forEach()
map()
filter()
reduce()
forEach()
map()
filter()
The function passed to the sort() method returns a value of true or false.
Question options:
1
2
3
68
When grading the question, it would appear as:
What does the following code display?
const date = "2/4/68";
const dateParts = date.split("/");
console.log(dateParts.length);
1
2
68
14) What does the optional limit parameter of the split()
method do?
When taking the question, it would appear as:
What does the optional limit parameter of the split() method do?
Question options:
It limits the type of values the new array can contain.
It specifies the maximum number of elements in the new array.
It limits the values that the separator parameter can accept.
It specifies the order of the elements in the new array.
When grading the question, it would appear as:
What does the optional limit parameter of the split() method do?
Two indexes are used to access a value that’s stored in an array of arrays.
An associative array can’t be used as an array within another array.
Arrays can only be nested two deep. In other words, you can’t have an array of arrays of
arrays.
An array of arrays must store a one-dimensional list of values.
18) What will the value of the totalsString variable be after the
following code is executed?const totals = [141.95, 212.95,
326.21, 491.95];totals[2] = 529.21;let totalsString = "";for
(const i in totals) { totalsString += i.toString() + "=" +
totals[i] + "|";}</
When taking the question, it would appear as:
What will the value of the totalsString variable be after the following code is executed?
const totals = [141.95, 212.95, 326.21, 491.95];
totals[2] = 529.21;
let totalsString = "";
for (const i in totals) {
totalsString += i.toString() + "=" + totals[i] + "|";
}
alert(totalsString);
Question options:
0=141.95|1=529.21|2=326.21|3=491.95|
0=141.95|1=212.95|2=529.21|3=491.95|
1=141.95|2=529.21|3=326.21|4=491.95|
1=141.95|2=212.95|3=529.21|4=491.95|
0=141.95|1=529.21|2=326.21|3=491.95|
0=141.95|1=212.95|2=529.21|3=491.95|
1=141.95|2=529.21|3=326.21|4=491.95|
1=141.95|2=212.95|3=529.21|4=491.95|
19) What does the second statement that follows do?let
numbers = [1, 2, 3, 4];numbers.length = 0;
When taking the question, it would appear as:
What does the second statement that follows do?
let numbers = [1, 2, 3, 4];
numbers.length = 0;
Question options:
Nothing.
Removes all the elements in the array.
Sets all the elements in the array to undefined.
Only changes the value of the length property.
When grading the question, it would appear as:
What does the second statement that follows do?
let numbers = [1, 2, 3, 4];
numbers.length = 0;
Nothing.
20) After the following code runs, what string is stored in the
variable named message?const answers = ["C", "B", "D",
"A"];delete answers[3];let message = "";for (const i in
answers) { message += answers[i];
When taking the question, it would appear as:
After the following code runs, what string is stored in the variable named message?
const answers = ["C", "B", "D", "A"];
delete answers[3];
let message = "";
for (const i in answers) {
message += answers[i];
}
Question options:
C
CBDundefined
CBA
CBD
When grading the question, it would appear as:
After the following code runs, what string is stored in the variable named message?
const answers = ["C", "B", "D", "A"];
delete answers[3];
let message = "";
for (const i in answers) {
message += answers[i];
}
C
CBDundefined
CBA
CBD
21) After the following code runs, what string it stored in the
variable named message?const answers = ["C", "B", "D",
"A"];delete answers[3];let message = "";for (const answer of
answers) { message += answer;
When taking the question, it would appear as:
After the following code runs, what string it stored in the variable named message?
const answers = ["C", "B", "D", "A"];
delete answers[3];
let message = "";
for (const answer of answers) {
message += answer;
}
Question options:
C
CBDundefined
CBA
CBD
When grading the question, it would appear as:
After the following code runs, what string it stored in the variable named message?
const answers = ["C", "B", "D", "A"];
delete answers[3];
let message = "";
for (const answer of answers) {
message += answer;
}
C
CBDundefined
CBA
CBD
Question options:
alert(employee[0] + " is " + employee[1]);
(Refer to code example 15-1) This code creates a tabular structure that has
Question options:
5 rows and 5 columns
4 rows and 4 columns
4 rows and 5 columns
3 rows and 5 columns
When grading the question, it would appear as:
Code example 15-1
const testScores = [];
testScores[0] = [80, 82, 90, 87, 85];
testScores[1] = [79, 80, 74, 82, 81];
testScores[2] = [93, 95, 89, 100, 85];
testScores[3] = [60, 72, 65, 71, 79];
(Refer to code example 15-1) This code creates a tabular structure that has
testScores[1][3]
testScores[2][2]
testScores[3][1]
(Refer to code example 15-1) Which of the following returns a value of 89?
testScores[0][4]
testScores[1][3]
testScores[2][2]
testScores[3][1]
JSON can only be used to store Array objects, not other objects such as Date objects.
JSON uses a binary format to store and transmit the data for an object.
JSON can only be used with JavaScript, not other languages such as PHP.
JSON uses text to store and transmit the data for an object such as an Array object.
Question options:
const json = JSON.toString(instruments);
28) After the following code executes, what values are stored
in the set named idsSet?const ids = [1, 2, 3, 2, 4];const idsSet
= new Set(ids);
When taking the question, it would appear as:
After the following code executes, what values are stored in the set named idsSet?
const ids = [1, 2, 3, 2, 4];
const idsSet = new Set(ids);
Question options:
1, 2, 3
1, 3, 4
1, 2, 3, 4
1, 2, 3, 2, 4
1, 2, 3
1, 3, 4
1, 2, 3, 4
1, 2, 3, 2, 4
Question options:
mary@murach.com
Mary Wigginton
Mary Delamater
mary@murach.com
Mary Wigginton
Mary Delamater
3 properties
3 methods
2 properties and 1 method
(Refer to code example 16-1) Given the following constant for the subtotal of an invoice,
which of the following statements gets the total for invoice?
const subtotal = 100;
Question options:
const total = getTotal(subtotal);
(Refer to code example 16-1) Given the following constant for the subtotal of an invoice,
which of the following statements gets the total for invoice?
const subtotal = 100;
let
this
create
new
5) You can create most of the native object types by assigning
a literal value to a variable or constant. Which native object
type requires you to use the new keyword to create an object?
When taking the question, it would appear as:
You can create most of the native object types by assigning a literal value to a variable or
constant. Which native object type requires you to use the new keyword to create an object?
Question options:
Date
Number
String
Object
When grading the question, it would appear as:
You can create most of the native object types by assigning a literal value to a variable or
constant. Which native object type requires you to use the new keyword to create an object?
Date
Number
String
Object
Question options:
The getFullYear() method of both variables returns 2017.
The getFullYear() method of both variables returns 2018.
The getFullYear() method of the today variable returns 2018 and the getFullYear() method of the now varia
The getFullYear() method of both variables returns undefined.
When grading the question, it would appear as:
Which of the following statements is true after the code below is executed?
let today = new Date("2017-06-01");
let now = today;
today.setFullYear(2018);
The getFullYear() method of the today variable returns 2018 and the getFullYear()
method of the now variable returns 2017.
The getFullYear() method of both variables returns undefined.
new
this
readonly
get
Question options:
The third party jQuery library should be included before the custom mpg library.
The larger jQuery library should be included before the smaller mpg library.
The mpg library contains code that depends on the jQuery library.
JavaScript files should be included in alphabetical order.
When grading the question, it would appear as:
Why might the script tags for these library files be coded in this order?
<script src="jquery-3.4.1.min.js"></script>
<script src="lib_mpg.js"></script>
The third party jQuery library should be included before the custom mpg library.
The larger jQuery library should be included before the smaller mpg library.
The mpg library contains code that depends on the jQuery library.
getFullName() {
return this.firstName + " " + this.lastName;
}
}
(Refer to code example 16-2) This code creates an Employee object type that contains
Question options:
2 methods
1 constructor and 1 method
1 constructor and 2 properties
1 constructor, 2 properties, and 1 method
When grading the question, it would appear as:
Code example 16-2
class Employee {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
getFullName() {
return this.firstName + " " + this.lastName;
}
}
(Refer to code example 16-2) This code creates an Employee object type that contains
2 methods
1 constructor and 1 method
1 constructor and 2 properties
getFullName() {
return this.firstName + " " + this.lastName;
}
}
Question options:
Grace
Hopper
Grace Hopper
Hopper Grace
When grading the question, it would appear as:
Code example 16-2
class Employee {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
getFullName() {
return this.firstName + " " + this.lastName;
}
}
Grace
Hopper
Grace Hopper
Hopper Grace
getFullName() {
return this.firstName + " " + this.lastName;
}
}
Question options:
Hopper
Slick
Grace Slick
Grace Hopper
When grading the question, it would appear as:
Code example 16-2
class Employee {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
getFullName() {
return this.firstName + " " + this.lastName;
}
}
Hopper
Slick
Grace Slick
Grace Hopper
18) Code example 16-2class Employee {
constructor(firstName, lastName) { this.firstName =
firstName; this.lastName = lastName; }
getFullName() { return th
When taking the question, it would appear as:
Code example 16-2
class Employee {
constructor(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
getFullName() {
return this.firstName + " " + this.lastName;
}
}
(Refer to code example 16-2) Which of the following could be used to convert the
getFullName() method to a read-only property named fullName?
Question options:
fullName {
return this.firstName + " " + this.lastName;
}
fullName => {
return this.firstName + " " + this.lastName;
}
get fullName() {
return this.firstName + " " + this.lastName;
}
set fullName() {
return this.firstName + " " + this.lastName;
}
getFullName() {
return this.firstName + " " + this.lastName;
}
}
(Refer to code example 16-2) Which of the following could be used to convert the
getFullName() method to a read-only property named fullName?
fullName {
return this.firstName + " " + this.lastName;
}
fullName => {
return this.firstName + " " + this.lastName;
}
get fullName() {
return this.firstName + " " + this.lastName;
}
set fullName() {
return this.firstName + " " + this.lastName;
}
23) Assume that you have an object named employee that only
has two properties named firstName and lastName. What does
the following code do?employee.streetAddress = "123 Main
Street";
When taking the question, it would appear as:
Assume that you have an object named employee that only has two properties named
firstName and lastName. What does the following code do?
employee.streetAddress = "123 Main Street";
Question options:
It adds a method named streetAddress() to the employee object.
It adds a property named streetAddress to the employee object.
It adds an event named streetAddress to the employee object.
It causes an error because no property named streetAddress exists for the employee object.
When grading the question, it would appear as:
Assume that you have an object named employee that only has two properties named
firstName and lastName. What does the following code do?
employee.streetAddress = "123 Main Street";
Question options:
It adds a method named toTestString() to the prototype object that Date objects are cloned from.
It adds a method named toTestString() to the current Date object but not to other Date objects that are create
It adds a property named toTestString to the prototype object that Date objects are cloned from.
It causes an error because no method named toTestString() exists for the Date object.
When grading the question, it would appear as:
What does the following code do?
Date.prototype.toTestString = function() {
return "Test";
};
It adds a method named toTestString() to the prototype object that Date objects are
cloned from.
It adds a method named toTestString() to the current Date object but not to other Date
objects that are created later.
It adds a property named toTestString to the prototype object that Date objects are
cloned from.
It causes an error because no method named toTestString() exists for the Date object.
Question options:
for (const task of taskList) {
console.log(task)
}
for (const task of taskList.tasks) {
console.log(task)
}
for (const i in taskList.tasks) {
console.log(taskList.tasks[i])
}
for (let i = 0; i < taskList.tasks.length; i++) {
console.log(taskList.tasks[i])
}
Question options:
const firstName = person.firstName;
const lastName = person.lastName;