Uploaded by yephereforit

Scripting Languages Test Questions

advertisement
Test #1
Question Pool
124 questions
Multiple Choice
A key characteristic that sets scripting languages apart from other programming languages is that _____.
1. Option 1
scripting languages must be compiled before they are run
2. Option 2
scripting languages are run directly from a program, not compiled
Correct answer
3. Option 3
non-scripting languages require an interpreter to run
4. Option 4
non-scripting languages are not converted into machine code
Automated feedback
Multiple Choice
A(n) _____ transforms a set of instructions written in a programming language into machine code, which can
be understood by a computer.
1. Option 1
browser
2. Option 2
scripter
3. Option 3
interpreter
4. Option 4
compiler
Correct answer
Automated feedback
Multiple Choice
A(n) _____ reads the code of a program line by line, scanning for errors, as the program is run.
1. Option 1
interpreter
Correct answer
2. Option 2
compiler
3. Option 3
script
4. Option 4
CSS
Automated feedback
Multiple Choice
Which statement is correct?
1. Option 1
A markup language called JavaScript provides tools for interacting with web pages.
2. Option 2
A scripting language called Java is used to create and compile web browsers.
3. Option 3
A markup language called HTML is used to define the content and structure of a web page.
Correct answer
4. Option 4
A scripting language called CSS is used to define how a web page will appear on a device.
Automated feedback
Multiple Choice
JavaScript _____.
1. Option 1
was once supported by Internet Explorer only in a different form called JScript
Correct answer
2. Option 2
was developed by the European Computer Manufacturers Association
3. Option 3
has benefited from a single set of governing standards since it was introduced
4. Option 4
was not supported by major browsers for the first 11 years that it existed
Automated feedback
Multiple Choice
What is the relationship between JavaScript and ECMAScript?
1. Option 1
JavaScript and ECMAScript are two different scripting languages for web pages.
2. Option 2
JavaScript is the most important implementation of ECMAScript.
Correct answer
3. Option 3
ECMAScript is the most recent version of JavaScript.
4. Option 4
Changes to JavaScript are adopted by ECMAScript within a few years of their release.
Automated feedback
Multiple Choice
The Document Object Model _____.
1. Option 1
is an important part of ECMAScript
2. Option 2
specifications are managed by the European Computer Manufacturers Association
3. Option 3
describes how to access the contents of a web page and user actions within that page
Correct answer
4. Option 4
describes how to access the features and behaviors of a browser
Automated feedback
Multiple Choice
Which statement about the BOM is correct?
1. Option 1
JavaScript does not directly interact with the BOM.
2. Option 2
A formal set of standards for the BOM is maintained by the W3C.
3. Option 3
The BOM describes how to access a web page’s contents.
4. Option 4
The BOM is largely the same among the various browsers currently available.
Correct answer
Automated feedback
Multiple Choice
What is an API?
1. Option 1
a system consisting of a client and a server
2. Option 2
a system for exchanging data on the web
3. Option 3
a set of procedures that access an application
Correct answer
4. Option 4
a scripting programming language
Automated feedback
Multiple Choice
Which statement about a client/server architecture is correct?
1. Option 1
The server fulfills the client’s information request.
Correct answer
2. Option 2
The server presents an interface to the user.
3. Option 3
The client usually houses any required databases.
4. Option 4
The client performs none of the required processing.
Automated feedback
Multiple Choice
HTTP is important for the web’s client/server system because _____.
1. Option 1
it tells the client how to format data for the user
2. Option 2
it provides the logic used by the server for processing data
3. Option 3
it supplies the procedures needed to access applications
4. Option 4
it is the protocol used for data exchange between the client and server
Correct answer
Automated feedback
Multiple Choice
What is the key difference between a two-tier and a three-tier client/server system?
1. Option 1
In a three-tier system, the client is split into a user interface tier and a data exchange tier.
2. Option 2
In a three-tier system, the database is split into a processing tier and a data storage tier.
Correct answer
3. Option 3
A three-tier system must include three physical computers rather than two.
4. Option 4
More of the processing in a three-tier system is performed by the client.
Automated feedback
Multiple Choice
Server-side scripting is used to _____.
1. Option 1
access or manipulate the user’s web browser
2. Option 2
directly access a database on a system’s back end
Correct answer
3. Option 3
handle the processing needed to display a user interface
4. Option 4
translate a request from a client into HTML
Automated feedback
Multiple Choice
Which of the following languages is used for server-side scripting?
1. Option 1
HTML
2. Option 2
JavaScript
3. Option 3
Ruby
Correct answer
4. Option 4
Java
Automated feedback
Multiple Choice
Using client-side scripting to handle light processing tasks such as data validation _____.
1. Option 1
minimizes transfer times across the Internet, making web applications faster
Correct answer
2. Option 2
confines processing to fewer hardware devices, limiting processing power
3. Option 3
increases server resource requirements and the related infrastructure costs
4. Option 4
is not possible, as you must use server-side scripting to validate forms
Automated feedback
Multiple Choice
What is the role of the IDE in a JavaScript developer’s workflow?
1. Option 1
It describes how to access the contents of and user interactions with web pages.
2. Option 2
It is a component of a web browser responsible for enforcing security restrictions.
3. Option 3
It provides a means for accessing and manipulating a back-end database using JavaScript.
4. Option 4
It is used to manage all aspects of website development, including writing and testing code.
Correct answer
Automated feedback
Multiple Choice
A code editor _____.
1. Option 1
is considered a poor choice for combined JavaScript, HTML, and CSS development
2. Option 2
is typically more expensive to purchase than development environment software
3. Option 3
is an alternate name for a basic text editor, which can be used to write JavaScript
4. Option 4
color codes the entered text to denote JavaScript keywords and user-defined values
Correct answer
Automated feedback
Multiple Choice
What code lines would you place before and after a set of JavaScript statements to embed them in an HTML
file?
1. Option 1
<script> and </script>
Correct answer
2. Option 2
script.execute; { and }
3. Option 3
<javascript> and </javascript>
4. Option 4
/* and */
Automated feedback
True/False
Programmers are not required to end JavaScript statements with semicolons, but it is considered good practice
to do so.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
Which of the following is a characteristic of an object used in JavaScript programming?
1. Option 1
includes procedures but not attributes
2. Option 2
includes attributes but not procedures
3. Option 3
includes both programming code and data
Correct answer
4. Option 4
always unique to and created for the program
Automated feedback
Multiple Choice
Which JavaScript statement assigns the value 3.49 to the price property of the hotChocolate object?
1. Option 1
hotChocolate.write(price, 3.49);
2. Option 2
hotChocolate.price = 3.49;
Correct answer
3. Option 3
hotChocolate.price(3.49);
4. Option 4
price.hotChocolate = 3.49
Automated feedback
Multiple Choice
Which JavaScript statement calls a method associated with the hotChocolate object, passing the argument
1 to this method?
1. Option 1
hotChocolate.addToOrder(1);
Correct answer
2. Option 2
hotChocolate.addToOrder = 1;
3. Option 3
addToOrder.hotChocolate(1);
4. Option 4
method.hotChocolate(addToOrder, 1);
Automated feedback
Multiple Choice
In JavaScript, _____.
1. Option 1
the statement document.write(True); instructs the browser to execute the following block of code
within a web page
2. Option 2
the statement document.write("Today’s special: dumplings!"); can be used to display a
message on a web page
Correct answer
3. Option 3
the document.write() method should be used to display static text in a web browser when a document is
first rendered
4. Option 4
the document.write() method should be used only for large blocks of content and should be placed in a
separate file, not embedded in an HTML file
Automated feedback
Multiple Choice
When naming and using variables in JavaScript, you should remember that _____.
1. Option 1
Shelter and HomelessPet are appropriate for object names
2. Option 2
the interpreter will still recognize the variable called shelter if you capitalize it as SHELTER
3. Option 3
you cannot assign identifiers that include capital letters, such as homelessPet, to variables
4. Option 4
shelter and homelesspet are appropriate names for objects
Correct answer
Automated feedback
Multiple Choice
What would you place in the blank in the following JavaScript code to insert a note for other programmers to
read that the interpreter would ignore?
<script>
document.write("Today’s stock prices"); _____
</script>
1. Option 1
** Need to replace with dynamic content
2. Option 2
{Need to replace with dynamic content}
3. Option 3
// Need to replace with dynamic content
Correct answer
4. Option 4
/* Need to replace with dynamic content //
Automated feedback
Multiple Choice
A variable used in a program written in JavaScript _____.
1. Option 1
should be created and assigned after its name is used in calculations
2. Option 2
is assigned a memory location but not a name
3. Option 3
is a specific location in the computer’s memory
Correct answer
4. Option 4
stores data that does not change during a program’s execution
Automated feedback
Multiple Choice
Suppose you need to create a variable to represent a color choice for an item. Which variable name should you
assign to it to follow JavaScript rules and conventions?
1. Option 1
itemColor
Correct answer
2. Option 2
item color
3. Option 3
10color
4. Option 4
let Item_Color
Automated feedback
Multiple Choice
Which of the following lists contains only JavaScript keywords?
1. Option 1
case, goto, i, synchronized
2. Option 2
await, delete, enum, interface
Correct answer
3. Option 3
async, final, long, while
4. Option 4
extends, private, TRUE, yes
Automated feedback
Multiple Choice
Which of the following JavaScript statements will NOT succeed in declaring the speedLimit variable and
assigning the value of 70 to it?
1. Option 1
let speedLimit = 70;
2. Option 2
let speedLimit;
speedLimit = 70;
3. Option 3
let speedLimit = 70, speedUnit = "MPH";
4. Option 4
speedLimit = 70;
let speedLimit;
Correct answer
Automated feedback
Multiple Choice
When a variable is declared and initialized with the statement var velocity = 32;, this means that
_____.
1. Option 1
it has a somewhat different scope than if it were declared using the let keyword
Correct answer
2. Option 2
it stores a constant value that cannot be changed
3. Option 3
the variable velocity can only hold a numerical value, not a text string
4. Option 4
the variable velocity was declared and initialized without using an assignment operator
Automated feedback
Multiple Choice
Which statement should you use to declare a variable called accelerationOfGravity that will store a
constant value that cannot be changed?
1. Option 1
let accelerationOfGravity = 9.8;
2. Option 2
var accelerationOfGravity;
accelerationOfGravity = 9.8;
3. Option 3
const accelerationOfGravity = 9.8;
Correct answer
4. Option 4
const.accelerationOfGravity(9.8);
Automated feedback
Multiple Choice
Suppose you have initialized two variables containing integers called qtyOne and qtyTwo. How would you
write a JavaScript expression to declare a totalQty variable and assign the sum of qtyOne and qtyTwo as
its value?
1. Option 1
totalQty = sum(qtyOne, qtyTwo);
2. Option 2
document.write(totalQty, qtyOne + qtyTwo);
3. Option 3
qtyOne + qtyTwo = totalQty;
4. Option 4
let totalQty = qtyOne + qtyTwo;
Correct answer
Automated feedback
Multiple Choice
You can use the addition operator (+) in several ways in JavaScript. However, you CANNOT use the addition
operator to _____.
1. Option 1
combine the text string "Your score is: " with the integer 20 in displayed text
2. Option 2
add the integer 10 and the string "10" to return the integer 20
Correct answer
3. Option 3
perform arithmetic operations using the names of variables with integer values
4. Option 4
combine the text string "Good morning, " with the value of firstName
Automated feedback
True/False
The operands in the JavaScript expression "ABC" + 123 + doReMe are: "ABC", 123, and doReMe.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
Which element of the JavaScript expression document.write("<p>The current time in " +
cityName + " is " + currentTime + ".</p>"); is a literal?
1. Option 1
cityName
2. Option 2
"<p>The current time in "
Correct answer
3. Option 3
document
4. Option 4
write
Automated feedback
Multiple Choice
Suppose you have initialized a variable in your JavaScript program using this statement:
let weight = 130;
What expression should you use to modify the value of weight later in the program?
1. Option 1
weight = 115;
Correct answer
2. Option 2
let weight;
weight = 115;
3. Option 3
weight.value = 115;
4. Option 4
weight2 = weight + 115;
Automated feedback
True/False
In the context of programming web applications, a user typing in a form field with a keyboard, the occurrence
of an error as a browser attempts to load a page, and a user touching a webpage element on a mobile phone
screen are all examples of events.
1. TrueCorrect answer
2. False
Automated feedback
True/False
JavaScript programmers must include code to respond to the complete set of trigger events in each script
because all events occur with all devices that run browser applications.
1. True
2. FalseCorrect answer
Automated feedback
Multiple Choice
Which of the following lines of code correctly uses an event handler attribute to display a dialog box when the
webpage user clicks or taps a submit button?
1. Option 1
<select type="submit" onclick="window.alert(Welcome!)" />
-50 %
2. Option 2
<input type="submit" onclick=window.alert("Welcome!") />
-50 %
3. Option 3
<input type="submit" onclick="window.alert('Welcome!')" />
Correct answer100 %
4. Option 4
<input type="submit" onblur="window.alert('Welcome!')" />
-50 %
Automated feedback
True/False
The JavaScript window.alert() method makes a dialog box appear that contains the literal string passed
to it plus an OK button that can be clicked to close the box.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
Suppose you want to change the source file for the image element with the id value shirtPhoto so that a
blue shirt is shown when the webpage user clicks a blue swatch image on the page. The photo’s file name is
stored in the variable blueShirtImage. What JavaScript event handler could you attach to the swatch
image element?
1. Option 1
onclick="shirtPhoto.getElementById.src = blueShirtImage"
2. Option 2
onclick=document.getElementsById('shirtPhoto').src = blueShirtImage
3. Option 3
onclick="document.getElement('shirtPhoto').src = blueShirtImage"
4. Option 4
onclick="document.getElementById('shirtPhoto').src = blueShirtImage"
Correct answer
Automated feedback
True/False
When you insert several JavaScript scripts into an HTML file, you must repeat statements declaring and
initializing variables in each script because the statements in one script are unavailable to other scripts in the
file.
1. True
2. FalseCorrect answer
Automated feedback
True/False
It is the best practice to place all JavaScript scripts at the beginning of an HTML file so that they will not be
run until after the Document Object Model has been created.
1. True
2. FalseCorrect answer
Automated feedback
True/False
When the following script element is inserted into an HTML file to instruct the browser to load a
JavaScript file, the name and location of the HTML file belong in the blank.
<script src="_____"></script>
1. True
2. FalseCorrect answer
Automated feedback
True/False
You should add the defer attribute to the script element attaching an external JavaScript file to an HTML
file when you want the browser to load the HTML file completely, then load and process the script.
1. TrueCorrect answer
2. False
Automated feedback
True/False
When the file magnolia.js is attached to a web page by inserting the following line into its HTML file, the
browser will load the HTML and JavaScript files together until the script is loaded, pause loading of the
HTML to process the script, then complete loading of the HTML. Answer is True
<script src="magnolia.js" async></script>
1. TrueCorrect answer
2. False
Automated feedback
True/False
When you link an HTML file to an external JavaScript file using the src attribute of the script element,
you must update the HTML file every time the script is modified to prevent load-time errors.
1. True
2. FalseCorrect answer
Automated feedback
True/False
JavaScript libraries such as Node.js and jQuery can be downloaded and then utilized to create and manage
large web applications more effectively when connected to the HTML file through a script element in the
head section.
1. TrueCorrect answer
2. False
Automated feedback
True/False
If all of the major browsers can render a web page, this indicates that the HTML document used to produce it
is well formed.
1. True
2. FalseCorrect answer
Automated feedback
True/False
An HTML document that is well formed and correctly written according to the element definitions in HTML’s
specific language definition is considered a valid document.
1. TrueCorrect answer
2. False
Automated feedback
True/False
Enclosing embedded JavaScript statements within a script element of an XHTML document in a CDATA
section causes them to be treated as parsed character data, which will invalidate the XHTML document.
Answer is True
1. True
2. FalseCorrect answer
Automated feedback
True/False
Enclosing embedded JavaScript statements within a script element of an XHTML document in a CDATA
section causes them to be treated as parsed character data, which will invalidate the XHTML document.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
What programming structure that can be called repeatedly throughout a program consists of a collection of
statements that share a common purpose or calculate a value?
1. Option 1
parameter
2. Option 2
function
Correct answer
3. Option 3
command block
4. Option 4
object
Automated feedback
Multiple Choice
How would you write a named function that displays a sentence with two parameters values inserted in an alert
box?
1. Option 1
function (size, topping) {
window.alert("Your free " + size + " pizza topped with " + topping " is
on its way!");
}
2. Option 2
pizzaConf function(size, topping) {
window.alert("Your free " + size + " pizza topped with " + topping " is
on its way!");
}
3. Option 3
function pizzaConf(size, topping) {
window.alert("Your free " + size + " pizza topped with " + topping " is
on its way!");
}
Correct answer
4. Option 4
function (size, topping) {
return size;
}
Automated feedback
Multiple Choice
Suppose you have written the following function.
function salesTax(price, rate) {
let tax = price * rate;
return tax;
{
How can you make it an anonymous function?
1. Option 1
remove salesTax
Correct answer
2. Option 2
remove function
3. Option 3
add anonymous before function
4. Option 4
remove the curly braces
Automated feedback
Multiple Choice
A function included within a procedural program _____.
1. Option 1
is always a named method
2. Option 2
should be called only once with known arguments
3. Option 3
must always return a value
4. Option 4
can be called repeatedly to increase the code’s efficiency
Correct answer
Automated feedback
Multiple Choice
An important distinction between methods and functions is that _____.
1. Option 1
functions can be called only once in a program
2. Option 2
methods can be called only once in a program
3. Option 3
methods are actions associated with an object
Correct answer
4. Option 4
functions are attributes associated with an object
Automated feedback
Multiple Choice
Suppose you have written the following function.
function salesTax(price, rate) {
let tax = price * rate;
return tax;
{
How can you call the function, passing in values of 9% for the sales tax rate and $20 for the price?
1. Option 1
salesTax(20, 0.09);
Correct answer
2. Option 2
salesTax(0.09, 20);
3. Option 3
function salesTax(20, 0.09);
4. Option 4
tax = 20 * 0.09;
Automated feedback
Multiple Choice
What is wrong with the following function to calculate the slope of a line?
function slope(rise, run) {
return ratio;
let ratio = rise / run;
}
1. Option 1
The curly braces are incorrectly placed.
2. Option 2
The wrong variable value is returned by the function.
3. Option 3
The incorrect reserved word was used at the beginning.
4. Option 4
The calculation statement was placed after the return statement.
Correct answer
Automated feedback
Multiple Choice
Suppose you want to execute the calcCredit function when the element <input type="button"
id="credit" value="Calculate" /> is clicked. How can you do this?
1. Option 1
Insert the calcCredit function before the />.
2. Option 2
Add onclick="calcCredit()" before the />.
Correct answer
3. Option 3
Add click="calcCredit()" before value="Calculate".
4. Option 4
Insert event="click" function="calcCredit()" before the />.
Automated feedback
Multiple Choice
Full credit given
When HTML and JavaScript code are written in separate files, the command
document.getElementById("happy").onclick = makeIceCream; is used to _____.
1. Option 1
create an on-click event handler as an attribute of the happy object in an HTML file
-50 %
2. Option 2
place an on-click event handler for the happy object within JavaScript code
Correct answer100 %
3. Option 3
call the makeIceCream() function with happy as an argument
-50 %
4. Option 4
add an event listener for the happy object within JavaScript code
-50 %
Automated feedback
Multiple Choice
What belongs in the blank in the following JavaScript command if you want to run function1 in response
to the load event of the window object?
window._____("load", function1);
1. Option 1
addEventListener
Correct answer
2. Option 2
removeEventListener
3. Option 3
onload
4. Option 4
getElementById
Automated feedback
Multiple Choice
Which JavaScript method should you apply to respond to a click event that occurs within the page object with
the id total during the capture phase?
1. Option 1
document.getElementById("total").addEventListener("click", calcTotal);
2. Option 2
document.getElementById("total").addEventListener("click", calcTotal,
capture);
3. Option 3
document.getElementById("total").addEventListener("click", calcTotal,
false);
4. Option 4
document.getElementById("total").addEventListener("click", calcTotal,
true);
Correct answer
Automated feedback
True/False
The following JavaScript event listener will respond to the load event for the window object as it goes up
the object hierarchy: window.addEventListener("load", function1);.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
How do you use an event listener to trigger execution of an anonymous function?
1. Option 1
Pass the name of the function as the function argument to the addEventListener() method.
2. Option 2
Include the anonymous function within the addEventListener() method, but omit the curly braces.
3. Option 3
Insert the entire structure of the anonymous function as the function argument for the
addEventListener() method.
Correct answer
4. Option 4
You can’t; you can use anonymous functions with event handlers but not with event listeners.
Automated feedback
True/False
The only way to run a JavaScript function upon an event such as a page loading or a user clicking a page
element is to enclose the function within an event handler or event listener.
1. True
2. FalseCorrect answer
Automated feedback
Multiple Choice
Which built-in JavaScript function will return the integer 15 when called on the string "5 + 10"
1. Option 1
decodeURI(string)
2. Option 2
eval(string)
Correct answer
3. Option 3
parseInt(string)
4. Option 4
sum(string)
Automated feedback
Multiple Choice
Which statement about variable scope is correct?
1. Option 1
Variables declared with var have global scope.
2. Option 2
Variables declared with the let keyword have function scope.
3. Option 3
Variables declared with let are block scoped.
Correct answer
4. Option 4
Variables declared with the var keyword have block scope.
Automated feedback
True/False
The use of global variables is strongly discouraged for applications managed by a team of programmers
because, in comparison, the scope of local variables is well-contained and therefore more easily tracked.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
JavaScript primitive data types _____.
1. Option 1
include Booleans, which have a logical value of either true or false
Correct answer
2. Option 2
include null, the data type of a variable that has been declared but not initialized
3. Option 3
classify JavaScript as a statically typed language
4. Option 4
must be used with the object data type to specify the categories of information variables contain
Automated feedback
Multiple Choice
Which of the following would NOT be represented as a floating point number in JavaScript?
1. Option 1
4.77 ´ 106
2. Option 2
3.5
3. Option 3
-12
4. Option 4
89
Correct answer
Automated feedback
Multiple Choice
How would you express the number 0.0055 in exponential notation?
1. Option 1
5.5e-3
Correct answer
2. Option 2
5.5e3
3. Option 3
55 ´ 103
4. Option 4
0.0055
Automated feedback
True/False
You can use Boolean values to allow your program to decide which code blocks to execute.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
Which statement demonstrates an appropriate method for storing data in a multi-line-length text string in
JavaScript?
1. Option 1
let message = /* "Pretend this is a very long text string.";
2. Option 2
let message = "Pretend this is a very long //text string.";
3. Option 3
let message = "Pretend this is a very long" +" text string.";
Correct answer
4. Option 4
let `message` = 'Pretend this is a very long text string.';
Automated feedback
Multiple Choice
What change should be made to the JavaScript statement document.write("<p>Who likes the
song "Twinkle, Twinkle, Little Star"?</p>"); if the intention is to display the string: Who
likes the song “Twinkle, Twinkle, Little Star”?
1. Option 1
No changes are necessary.
2. Option 2
Remove </p> from the statement.
3. Option 3
Change the third and fourth double quotation marks into single quotation marks.
4. Option 4
Insert a backslash (\) before each of the double quotation marks around the song’s title.
Correct answer
Automated feedback
Multiple Choice
Which escape sequence, when added to a JavaScript string, will be interpreted as a new line?
1. Option 1
\\
2. Option 2
\n
Correct answer
3. Option 3
\r
4. Option 4
\t
Automated feedback
Multiple Choice
In JavaScript, a binary operator _____.
1. Option 1
appears in the statement distance++;
2. Option 2
is the same thing as a bitwise operator
3. Option 3
appears in the expression distance + 37
Correct answer
4. Option 4
cannot be used to perform arithmetic operations on a variable
Automated feedback
True/False
The JavaScript expression 36-- returns the value 34.
1. True
2. FalseCorrect answer
Automated feedback
Multiple Choice
Which JavaScript expressions both return the value 3?
1. Option 1
2+1 and 12%4
2. Option 2
23%10 and 36/12
Correct answer
3. Option 3
2**1 and 5-2
4. Option 4
300/100 and 5**-2
Automated feedback
Multiple Choice
After the following JavaScript code executes, the value of c will be _____.
let a = 8;
let b = ++a;
let c = b--;
1. Option 1
8
2. Option 2
10
3. Option 3
7
4. Option 4
9
Correct answer
Automated feedback
True/False
The expression a *= b assigns b the value equal to a * b.
1. True
2. FalseCorrect answer
Automated feedback
Multiple Choice
The JavaScript expression discount == 10 _____.
1. Option 1
returns true if the number 10 is stored in the variable discount
Correct answer
2. Option 2
returns false if the number 10 is stored in the variable discount
3. Option 3
assigns the value 10 to the variable discount
4. Option 4
will result in an error because you cannot use variable names as operands with comparison operators
Automated feedback
Multiple Choice
The JavaScript statement let pizzaPrice = rewardsCustomer ? 20.0 : 18.5; _____.
1. Option 1
assigns the value of rewardsCustomer to the variable pizzaPrice because 20.0 is greater than 18.5
2. Option 2
assigns the value of rewardsCustomer to the variable pizzaPrice if it is between 20.0 and 18.5
3. Option 3
assigns the value 18.5 to the variable pizzaPrice if the value of rewardsCustomer is true
Correct answer
4. Option 4
assigns the value 18.5 to the variable pizzaPrice if the value of rewardsCustomer is undefined
Automated feedback
True/False
After the following JavaScript code executes, the message “Get back to work!” will display.
let holiday = 0
(holiday) ? window.alert("Enjoy your day off!") :
window.alert("Get back to work!");
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
What does this JavaScript statement do?
let thiefType = (goodDeeds > 10 && victimType === "wealthy") ? "rascal" :
"brigand";
1. Option 1
assigns "rascal" to thiefType only if the value of goodDeeds is greater than 10 and victimType
stores the string "wealthy"
Correct answer
2. Option 2
assigns "rascal" to thiefType if either the value of goodDeeds is greater than 10 or victimType
stores the string "wealthy"
3. Option 3
assigns the string "rascal brigand" to the variable thiefType
4. Option 4
assigns "rascal" to thiefType if the value of goodDeeds is greater than 10 but assigns "brigand"
to thiefType if victimType stores the string "wealthy"
Automated feedback
Multiple Choice
In JavaScript, if the variable flower has been assigned the value "bluebell", the expression
typeof(flower); will return _____.
1. Option 1
variable
2. Option 2
string
Correct answer
3. Option 3
bluebell
4. Option 4
void
Automated feedback
True/False
When the JavaScript expression (10 + 10) + 2 * 5 is evaluated, the addition within the parentheses is
performed first, then the multiplication operation, then the remaining addition operation.
1. TrueCorrect answer
2. False
Automated feedback
Multiple Choice
Which JavaScript expression can you use to retrieve the value from the web form input control with the id
“numberOfParticipants”?
1. Option 1
getInputValue("numberOfParticipants")
2. Option 2
let value = document.getElementById("numberOfParticipants")
3. Option 3
document.getElementById("numberOfParticipants").input
4. Option 4
document.getElementById("numberOfParticipants").value
Correct answer
Automated feedback
Multiple Choice
What does the JavaScript expression
document.getElementById("numberOfParticipants").value = 0; do?
1. Option 1
returns a Boolean true if the value of the input control with the id “numberOfParticipants” is 0
2. Option 2
retrieves the value entered by the user for the input control with the id “numberOfParticipants”
3. Option 3
sets the value of the input control with the id “numberOfParticipants” to 0
Correct answer
4. Option 4
results in an error because of incorrect syntax
Automated feedback
True/False
The following JavaScript expression retrieves the Boolean value false when the user has selected (ticked)
the box indicating he wants extra cheese, which has the id “extraCheese,” on a web form for ordering pizza.
document.getElementById("extraCheese").checked;
1. True
2. FalseCorrect answer
Automated feedback
Multiple Choice
Suppose you want to run the calcTotal() function each time the user of a web form changes an input
control with the id “quantity.” What belongs in the blank in this JavaScript statement?
document.getElementById("quantity")._____;
1. Option 1
onchange.calcTotal
2. Option 2
onchange = calcTotal
Correct answer
3. Option 3
onchange.value
4. Option 4
value = calcTotal
Automated feedback
True/False
Most browsers display error messages they generate in a console that can be opened by website developers,
and developers can use this console as a helpful debugging tool.
1. TrueCorrect answer
2. False
Automated feedback
True/False
When the Google Chrome browser console reports the location of an error as js40.js:30, this means it is found
on line 40 of the JavaScript file that prompted the error.
1. True
2. FalseCorrect answer
Automated feedback
Multiple Choice
Which JavaScript statement will create an array using an array literal?
1. Option 1
let sherbets = {"orange", "lime", "lemon", "raspberry"};
2. Option 2
new Array = (sherbets, ["orange", "lime", "lemon", "raspberry"]);
3. Option 3
let sherbets = ["orange", "lime", "lemon", "raspberry"];
Correct answer
4. Option 4
arr sherbets = {"orange", "lime", "lemon", "raspberry"};
Automated feedback
Multiple Choice
Which JavaScript statement will define an array using an object constructor?
1. Option 1
bagels = new Array["cinnamon raisin", "sesame onion", "everything"];
-50 %
2. Option 2
new Array = ("cinnamon raisin", "sesame onion", "everything");
-50 %
3. Option 3
let bagels = {"cinnamon raisin", "sesame onion", "everything"};
-50 %
4. Option 4
let bagels = new Array("cinnamon raisin", "sesame onion", "everything");
Correct answer100 %
Automated feedback
Multiple Choice
For an array stored in the variable customers whose highest index value is 34, the customers.length
property will return the value _____.
1. Option 1
35
Correct answer
2. Option 2
34
3. Option 3
33
4. Option 4
null
Automated feedback
Multiple Choice
Suppose you have defined an array containing days of the week, and realize that you left off Saturday. Which
JavaScript statement should you use to add Saturday at the end of the array while ensuring the array’s length
will be equal to 7?
1. Option 1
daysOfWeek += "Saturday";
2. Option 2
daysOfWeek[6] = "Saturday";
Correct answer
3. Option 3
daysOfWeek[0] = "Saturday";
4. Option 4
daysOfWeek[7] = "Saturday";
Automated feedback
Multiple Choice
Which of the following statements creates an array of elements of the integer data type with a length
property value of 5?
1. Option 1
unitsSold.length = [5];
2. Option 2
let unitsSold[5] = 63;
3. Option 3
let unitsSold = [35, 88, 29, 37, 33];
Correct answer
4. Option 4
let unitsSold = ["77", "28", "34", "52", "45"];
Automated feedback
Multiple Choice
To simulate a matrix in JavaScript using a multidimensional array, _____.
1. Option 1
create an array whose elements are nested arrays, each of which contains the data for a row in the
matrix
Correct answer
2. Option 2
use the constructor to build a new Matrix object
3. Option 3
use the syntax array[x][y], where x is the number of rows and y is the number of columns in the matrix
4. Option 4
create an array for each column in the matrix and then define an array whose elements are the variables to
which you assigned the column arrays
Automated feedback
Multiple Choice
Using an expression, how can you reference the value 25 from the data structure defined by the following
JavaScript code?
let bingoCard = [
["B", "I", "N", "G", "O"],
[10, 4, 30, 18, 8],
[23, 14, 25, 27, 11],
[31,6, 2, 22, 13]
];
1. Option 1
bingoCard[3][3]
2. Option 2
bingoCard[2][2]
Correct answer
3. Option 3
bingoCard[2]
4. Option 4
bingoCard[3, 3]
Automated feedback
View 24 more questions
Download