QUESTION 1 How many times will this loop execute? var x = 0; for(var i = 8; i >=
ID: 3816362 • Letter: Q
Question
QUESTION 1
How many times will this loop execute?
var x = 0;
for(var i = 8; i >= 3; i--) {
x = x + 2;
}
6
7
5
0
QUESTION 2
"After the for-loop ends the value of the variable nameFound be false. Why?
var names = ['Smith', 'Jones', 'Thomas', 'Wilson', 'Green'];
for(i=0; i < names.length; i++) {
if(names[i] == 'Thomas')
nameFound = true;
else
nameFound = false;
}"
it is a law that all names must be lower case
the if-block test uses only 1 equal sign
because Thomas is not spelled correctly
"nameFound will be true the 3rd time through the loop, but will be overwritten as false for the 4th and 5th times"
5 points
QUESTION 3
"When you declare an array like the following, you are declaring an array literal: var cars = ['focus', 'yaris', 'mini'];"
True
False
QUESTION 4
What's this? x = {'name': 'Ralph', 'occupation': 'actor};
an object literal
an anonymous function
an array literal
an object constructor function
QUESTION 5
Using magic numbers in your code is a good practice (hint: it is not).
True
False
QUESTION 6
"Given this object, how would you assign the model to a variable named m?
var myCar = {make: 'Plymouth', model: 'Valiant', year: 1968}"
m = model.myCar;
m = model.model;
m = myCar.model;
myCar.model(m);
QUESTION 7
"What is displayed by the alert box?
var names = new Array(1, 2, 4, 8, 16, 32);
var index = 4;
alert(names[index]);"
4
2
8
None of these answers
QUESTION 8
If you intend to create many identical object instances it is best to use ____ to create the objects.
the direct instance method
the object literal method
the XHR instance method
an object constructor function you write
QUESTION 9
How many times will this loop execute?
x = 0;
sum = 0;
while(x < 4) {
sum = sum + 10;
}
an infinite number
3
0
4
QUESTION 10
What will the variable x hold after the loop finishes?
var x = 1;
for(var i = 0; i < 5; i++) {
x = x + 2;
}
11
8
6
9
QUESTION 11
You cannot assign a JavaScript function to a variable.
True
False
QUESTION 12
Each piece of data contained in an array is called a(n) ____
identament
quid
element
index
QUESTION 13
This program will produce an error. Why?
var x;
for(var i = 0; i < 12; i++) {
x = x + 2;
}
the variable i is illegally declared
the for-loop will never execute
this program will not produce an error
there is an attempt to read the value of x before x has been assigned a value
QUESTION 14
What is this?
x = function() {
y = 22/7;
return y;
};
a prototype
a line that will produce a error
an anonymous function
an object constructor function
QUESTION 15
The ____ method adds one or more elements to the end of an array
pop()
push()
pull()
unshift()
QUESTION 16
Properties or methods added to the ____ object become available to all instances of this object's children.</
maker
prototype
archetype
penultimate
QUESTION 17
A ____ statement restarts a loop with a new iteration
continue
break
next
default
QUESTION 18
You use the ____ method of the String class to split a string into an indexed array
shift(}
split()
extract()
slice()
QUESTION 19
Each repetition of a looping statement is called an iteration.
True
False
QUESTION 20
A(n) ____ statement is used to exit control statements
quit
gotoline
break
continue
6
7
5
0
Explanation / Answer
1)6
2)"nameFound will be true the 3rd time through the loop, but will be overwritten as false for the 4th and 5th times"
3)False
4)an object constructor function
5)false
7)8
8)an object constructor function you write
9)infinite
10)11
11)false
12)element
13)there is an attempt to read the value of x before x has been assigned a value
15)push
17)continue
18)slice
19)True
20)break
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.