CORRECT ANSWERS, STUDY THIS FOR GRADE A
1.What are the first and last numbers output by the code segment?
var c = 100;
while (c > 0)
{
console.log(c);
c -= 10;
}: 100 and 10
2.What numbers are output by the code segment?
for (c = 5; c < 10; c += 2)
{
console.log(c);
}: 5, 7, 9
3.The variable z is assigned
9. var z = x(3);
var x = function(y)
{
return y * y;
}: False
x is not assigned a function expression until after x is called. Since
function expres- sions are not hoisted, the call to x(3) causes an
exception.
4.What is output to the console?
var names = [];
names[0] = "Sue";
names[1] = "Bob";
names[2] = "Jeff";
console.log(names[0] + names[1]);: SueBob
5.What is output to the console?
var autos = ["Chevrolet", "Dodge", "Ford", "Ram"]; for (i = 0; i < 2; i++)
{
console.log(autos[i]);
1/
10
, }: Chevrolet, Dodge
6.Refer to the game object.
var game = {
2/
10