Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVASCRIPT Questions Question 10 Javascript arrays must contain items of the sam

ID: 3823385 • Letter: J

Question

JAVASCRIPT Questions

Question 10

Javascript arrays must contain items of the same type (ex: all numbers or all strings).

Question 10 options:

Question 9

In the following statement, the function show() is executed first.

$(".children").append("<p>Smart!</p>").show()

Question 9 options:

Question 12

You can only use variables that start with a $ if you are using jQuery.

Question 12 options:

Question 13

The load method always requests and returns JSON data.

Question 13 options:

Question 14

One benefit of using Ajax to get data for a web page is that the page doesn’t have to be reloaded into the browser.

Question 14 options:

Question 15

The JSONP for a web site tells you how you can use Ajax to get data from the site.

Question 15 options:

Question 16

Which of these is a valid way of including a javascript file named "myScript.js" on a web page?

Question 16 options:

<script file="myScript.js"></script>

<javascript file="myScript.js" />

<script src="myScript.js"></script>

<javascript rel="myScript.js"></javascript>

Question 19

Which of these javascript comment blocks is correct?

Question 19 options:

// This is a comment

<!-- This is a comment -->

/* This is a comment */

A and C

All of the above

Question 20

Which object represents a web page?

Question 20 options:

page object

document object

window object

site object

Question 21

When we talk about an object's property, we are describing...

Question 21 options:

Characteristics of objects

Things that happen to objects

The number of items in an object

The general composition of an object

Question 22

Which of the following statements is false? A JavaScript variable

Question 22 options:

is case-sensitive

can start with a $ sign

can start with a number

can contain an underscore

Question 24

After the if statement that follows is executed, what will the value of discountAmount be?


var discountAmount;
var orderTotal = 200;
if (orderTotal > 200) {
discountAmount = orderTotal * .3;
} else if (orderTotal > 100) {
discountAmount = orderTotal * .2;
} else {
discountAmount = orderTotal * .1;
}

Question 24 options:

0.0

20.0

40.0

60.0

Question 25

What is the value of x after this code has finished executing?

var x = 1;

while(x < 10) {
console.log(x);
x = x + 2;
}

Question 25 options:

1

9

10

11

Question 26

Which of the following is a valid statement for declaring and initializing a variable named length to a starting value of 120?

Question 26 options:

length = 120;

int length = 120;

var length = 120;

num length = 120;

Question 27

How many times will the while loop that follows be executed?

var months = 5;
var i = 1;
while (i < months) {
futureValue = futureValue * (1 + monthlyInterestRate);
i = i+1;
}

Question 27 options:

0

4

5

6

Question 28

What will futureValue contain after the for loop has been executed one time?


var years = 10;
var annualRate = 10;
var futureValue = 1000;
annualRate = annualRate / 100;
for ( i = 1; i <= years; i++ ) {
futureValue += futureValue * annualRate;
}

Question 28 options:

1000

1100

11000

1010

Question 29

Assume userName equals “Tom” and userAge equals 22. What is displayed in a dialog box when the following statement is executed?


alert(userAge + " is " + userName + "'s age.");

Question 29 options:

22 is Tom's age.

22
is Tom's age.

22 is Tom's age.

22
is Tom's age.

Question 30

Which of the following is true?

Question 30 options:

3 !== 'three'

3 === 'three'

5 < 3

3 >= 4.0 || 5 === 'five'

Question 31

Which of these statements is a valid way to add a "yummy" class to this div:

<div class="meatloaf">Mom's Meatloaf</div>

Question 31 options:

$('div.meatloaf').addClass("yummy");

$('div.meatloaf').classAdd("yummy");

$('.meatloaf').class("yummy");

'$.class(".meatloaf", "yummy");

Question 32

After the statement that follows is executed, rateText represents


var rateText = document.getElementById("rate");

Question 32 options:

the string that was entered in the HTML element with “rate” as its id attribute

the HTML element with “rate” as its id attribute

the value that was entered in the HTML element with “rate” as its id attribute

The following code


var display_error = function ( message ) {
    alert("Error: " + message);
}

Question 33 options:

creates a function named display_error.

creates a function and stores it in a variable named display_error.

creates a function named message.

calls a function named message.

var add = function( x, y ) {
    return ( x + y );
}
alert( add (5, 3) );

Question 34 (2 points)

(Refer to code example above) The function in this example

Question 34 options:

accepts 2 parameters and returns 2 values.

accepts 2 parameters and returns 1 value.

accepts 2 parameters and does not return a value.

does not accept a parameter and returns 1 value.

Given the following lines of code, what will be displayed in successive dialog boxes?


var answers = [ "C", "B", "D", "A" ];
delete answers[3];
for ( var i in answers ) {
alert (answers[i]);
}

Question 36 options:

C, B, and an error

C, B, D, undefined

C, B, A

C, B, D

True False

Explanation / Answer

10. True because array is collection of data of similar types.

30. option c is true because the compiler doesnot know numbernames.

26. option b is the correct syntax to declare an integer value

22. option c is false because javascript variable cannot start with number but it can have number after one letter.

21. option a because object is an entity having state and behavior (properties and method).

20. option b document object defines the logical structure of documents and the wayin which a document is accessed and manipulated.