COP 2500 Exam 1
When developing JavaScript programs, if the developer uses the type attribute for the <script></script> tag element, which of the following is correct?
"text/javascript"
What operator is used for concatenation?
+
Which of the following is a valid block comment in JavaScript?
/* This is a block comment */
Given the expression var sum = 19 + 83; which parts of the expression are operands?
19 and 83
The ternary operator, which can be used to replace an if/else conditional statement, requires how many operands?
3
Assuming good HTML form and embedded <script></script>, when using concatenation what output would display based on the statement: document.write(102 + 201);
303
Well-formed statements written in JavaScript end with __________.
; (semi-colon)
Website lifecycle is a request/response loop. A request is made when __________.
A user types in www.insertwhateverhere.com in the URL text box of a Web browser and hits the enter key
The comparison operator != = is used to determine what?
If two operands are not identical in value and type
The JavaScript logical not operator results in the __________.
Reverse evaluation of the condition
When asked to develop unobtrusive JavaScript this means that the JavaScript is __________.
Stored in an external file with a .js file extension
What is the primary difference between a while loop and a do/while loop?
While loops executes 0...n times; do/while loop executes 1...n times
The following JavaScript code is described as switch (color) { case "blue": alert("cold"); case "red": alert("hot"); default: alert("No temperature selected"); }
a. switch b. Multi-way decision c. Alternative to the if/else if condition d. All of the above
Bit is short for __________.
binary digit
To declare a constant, a value that cannot be changed during programming execution requires the use of keyword __________.
const
Which of the following is not a valid data type of that a variable can hold?
const
Decision-making constructs for control flow such as if, if/else, if/else if, and switch
control expressions
The variable named data is initialized as follows: var data = "Data data data"; and is reused later in the JavaScript program. Which of the following is not a valid reuse of the variable data?
data= 5.5
What is the difference between document.write() and document.writeln()?
document.writeln() advances the cursor to the next line whereas document.write() does not
JavaScript is a stand-alone scripting language like Perl and Python.
false
JavaScript is the same as Java and as HTML
false
Data hierarchy comprises bits, characters, __________, records, and files.
fields
JavaScript is used to enhance ________ Web pages for an interactive experience. a. HTTP
html
JavaScript can __________.
improve website usability
What is the output of the following JavaScript code? <script> var counter = 0; while( counter < 5 ) { document.writeln( counter * 2); } </script>
infinite loop
JavaScript programs are executed by a JavaScript _________ in a Web browser.
interpreter
Which of the following is not part of the three layers of a Web page?
java
&& and || are called what in JavaScript?
logical operators
JavaScript is a __________ programming language.
loosely typed
The following JavaScript code is an example of what type of loop? <script> var asterisk = "*"; for (var row = 0; row < 10; row++) { for (var column = 0; column < row; column++) { document.writeln(asterisk); } document.writeln("<br>"); } </script>
nested loop
When using the typeof() function what does a value of null mean?
no valid data types
Primitive data types are assigned __________.
single literal values
Assuming good HTML form and embedded <script></script>, when using concatenation what output would display based on the statement: document.write("The temperature is" + 89);
the temperature is 89
HTML Web page files are saved using file extension .htm or .html.
true
Numeric literals can be integers (whole numbers) and floating point (fractional numbers with a decimal point).
true
Composite data types, also known as complex types, consist of more than one component. Valid composite data types include all of the following except __________.
undefined
When naming variables in JavaScript, which of the following would not be valid?
var #32829;
What are the three looping constructs in JavaScript?
while,do/while,for