Deck 9: Additional Javascript Basics: Window Object, If Statement, Strings, Numbers, and Input Validation

ملء الشاشة (f)
exit full mode
سؤال
When should you use dialog boxes (alert, confirm, and prompt) for input and output?

A) Dialog boxes are new with HTML5 and, as such, they are gaining traction as the preferred technique for all input and output.
B) Use dialog boxes only when you want to draw sharp attention to something and you want to force the user to deal with the issue immediately.
C) Use dialog boxes for all text input, but not for numerical input.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Consider the following three strings:
"to be or not to be", "to", "tooth"
Which of the following shows the strings sorted into ascending lexicographical order (words that are considered less than other words should be at the left).

A) "to be or not to be", "to", "tooth"
B) "to", "tooth", "to be or not to be"
C) "to", "to be or not to be", "tooth"
سؤال
To embed a backslash character (\) within a JavaScript string, you need to use the ______ escape sequence.
سؤال
Provide a functionally equivalent, shorter version of the following code:
window.document.getElementById["name"]
سؤال
The following code generates a dialog box that contains a question and an input box:
prompt("What's your favorite color?", "");
Initially, what displays inside the input box?
سؤال
Suppose a variable x holds "dog". After the following code gets executed, what does x hold?
x += "fish";
سؤال
When the following code executes, what message does the dialog box display?
var month = "January";
if (month.toLowerCase() == "january") {
alert("It is " + month + "!");
}
سؤال
After the following code executes, what does x hold?
var location = "Taos, NM";
var x = location.charAt(location.length - 1);
سؤال
After the following code executes, what does x hold?
var animal = "porcupine";
var x = animal.lastIndexOf("p", 3);
سؤال
What does the following expression evaluate to?
39 % 10 / 4
سؤال
Which of the following is a function of the <code>window</code> object's <code>location</code> property?

A) Holds the URL of the current web page
B) Displays the title of the current web page
C) Displays the geographical position of the user's computer
سؤال
What is the syntax for generating a dialog that displays a message and does not receive input?

A) <code><msg>message</msg></code>
B) <code><quote>message</quote></code>
C) <code>alert(message);</code>
D) <code>prompt(message);</code>
سؤال
What is the syntax for generating a dialog that prompts the user to answer yes or no to a question?

A) <code><prompt>message</prompt></code>
B) <code><ask>message</ask></code>
C) <code>alert(message);</code>
D) <code>confirm(message);</code>
سؤال
What is an <code>if</code> statement's condition?

A) A condition is a break in a web page that displays as a blank line.
B) A condition is a pause generated by a screen reader.
C) A condition is a question, surrounded by parentheses, that evaluates to true or false.
سؤال
An <code>if</code> statement is an example of a:

A) declaration statement.
B) branching statement.
C) looping statement.
سؤال
Which of the following statements is correct regarding an initialization statement?

A) It tells the browser engine that the program uses JavaScript for its language.
B) It links the web page's HTML code to its JavaScript code.
C) It is a combination of a variable declaration and an assignment.
سؤال
The <code>window</code> object's <code>screen</code> property holds information about the monitor that is being used.
سؤال
A named constant is a special variable whose value is fixed.
سؤال
To break/split a string in JavaScript, you should terminate the first part of the string with a closing quote, insert a(n) ______, and start the next line's continuation string with an opening quote.
سؤال
A(n) __________ is a pictorial representation of the logic flow of a computer program.
سؤال
Proper coding conventions suggest that when there are JavaScript statements inside of braces ({}), you should do which of the following?

A) Indent the statements inside the braces.
B) Position each statement's first character in the same column as the braces.
C) Separate the statements with commas, not semicolons.
سؤال
How can you test two strings to see if they are equal?

A) Call the equal method.
B) Call the equals method.
C) Use the = operator.
D) Use the == operator.
سؤال
Suppose you have a variable named character. What is the best way to assign a double quote (") to character?

A) character = "
B) character = '"';
C) character = "'";
D) character = "\'";
سؤال
The *:not(a) pseudo-class selector selects which of the following?

A) All noteworthy elements
B) All elements except for a elements (links)
C) Elements that are siblings of the current element
سؤال
How can you round a price variable's value to the hundredths place (e.g., 204.89)?

A) Use the remainder operator, price % 2.
B) Use the division operator, price / 2.
C) Call the round method, price.round(2).
D) Call the toFixed method, price.toFixed(2).
سؤال
The window object is known as the global object because all of its members are global.
سؤال
A dialog box is a control that supports verbal two-way communication between the user and the computer.
سؤال
A block statement (zero or more statements surrounded by braces) can be used anywhere a standard statement can be used.
سؤال
For the "if, else if, else" form of the if statement, if a condition is found to be true, that condition's block statement is executed. Then, all the other conditions are skipped, and control flows down to the statement below the entire if statement.
سؤال
The output element is for holding the result of a user's action.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/30
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 9: Additional Javascript Basics: Window Object, If Statement, Strings, Numbers, and Input Validation
1
When should you use dialog boxes (alert, confirm, and prompt) for input and output?

A) Dialog boxes are new with HTML5 and, as such, they are gaining traction as the preferred technique for all input and output.
B) Use dialog boxes only when you want to draw sharp attention to something and you want to force the user to deal with the issue immediately.
C) Use dialog boxes for all text input, but not for numerical input.
B
2
Consider the following three strings:
"to be or not to be", "to", "tooth"
Which of the following shows the strings sorted into ascending lexicographical order (words that are considered less than other words should be at the left).

A) "to be or not to be", "to", "tooth"
B) "to", "tooth", "to be or not to be"
C) "to", "to be or not to be", "tooth"
C
3
To embed a backslash character (\) within a JavaScript string, you need to use the ______ escape sequence.
\\
4
Provide a functionally equivalent, shorter version of the following code:
window.document.getElementById["name"]
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
5
The following code generates a dialog box that contains a question and an input box:
prompt("What's your favorite color?", "");
Initially, what displays inside the input box?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
6
Suppose a variable x holds "dog". After the following code gets executed, what does x hold?
x += "fish";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
7
When the following code executes, what message does the dialog box display?
var month = "January";
if (month.toLowerCase() == "january") {
alert("It is " + month + "!");
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
8
After the following code executes, what does x hold?
var location = "Taos, NM";
var x = location.charAt(location.length - 1);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
9
After the following code executes, what does x hold?
var animal = "porcupine";
var x = animal.lastIndexOf("p", 3);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
10
What does the following expression evaluate to?
39 % 10 / 4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following is a function of the <code>window</code> object's <code>location</code> property?

A) Holds the URL of the current web page
B) Displays the title of the current web page
C) Displays the geographical position of the user's computer
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
12
What is the syntax for generating a dialog that displays a message and does not receive input?

A) <code><msg>message</msg></code>
B) <code><quote>message</quote></code>
C) <code>alert(message);</code>
D) <code>prompt(message);</code>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
13
What is the syntax for generating a dialog that prompts the user to answer yes or no to a question?

A) <code><prompt>message</prompt></code>
B) <code><ask>message</ask></code>
C) <code>alert(message);</code>
D) <code>confirm(message);</code>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
14
What is an <code>if</code> statement's condition?

A) A condition is a break in a web page that displays as a blank line.
B) A condition is a pause generated by a screen reader.
C) A condition is a question, surrounded by parentheses, that evaluates to true or false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
15
An <code>if</code> statement is an example of a:

A) declaration statement.
B) branching statement.
C) looping statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which of the following statements is correct regarding an initialization statement?

A) It tells the browser engine that the program uses JavaScript for its language.
B) It links the web page's HTML code to its JavaScript code.
C) It is a combination of a variable declaration and an assignment.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
17
The <code>window</code> object's <code>screen</code> property holds information about the monitor that is being used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
18
A named constant is a special variable whose value is fixed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
19
To break/split a string in JavaScript, you should terminate the first part of the string with a closing quote, insert a(n) ______, and start the next line's continuation string with an opening quote.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
20
A(n) __________ is a pictorial representation of the logic flow of a computer program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
21
Proper coding conventions suggest that when there are JavaScript statements inside of braces ({}), you should do which of the following?

A) Indent the statements inside the braces.
B) Position each statement's first character in the same column as the braces.
C) Separate the statements with commas, not semicolons.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
22
How can you test two strings to see if they are equal?

A) Call the equal method.
B) Call the equals method.
C) Use the = operator.
D) Use the == operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
23
Suppose you have a variable named character. What is the best way to assign a double quote (") to character?

A) character = "
B) character = '"';
C) character = "'";
D) character = "\'";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
24
The *:not(a) pseudo-class selector selects which of the following?

A) All noteworthy elements
B) All elements except for a elements (links)
C) Elements that are siblings of the current element
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
25
How can you round a price variable's value to the hundredths place (e.g., 204.89)?

A) Use the remainder operator, price % 2.
B) Use the division operator, price / 2.
C) Call the round method, price.round(2).
D) Call the toFixed method, price.toFixed(2).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
26
The window object is known as the global object because all of its members are global.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
27
A dialog box is a control that supports verbal two-way communication between the user and the computer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
28
A block statement (zero or more statements surrounded by braces) can be used anywhere a standard statement can be used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
29
For the "if, else if, else" form of the if statement, if a condition is found to be true, that condition's block statement is executed. Then, all the other conditions are skipped, and control flows down to the statement below the entire if statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
30
The output element is for holding the result of a user's action.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.