Question: for javascript question 1 If totalMonths has a string value of 13, what does the code that follows display? var years = parseInt ( totalMonths

for javascript

question 1

If totalMonths has a string value of "13", what does the code that follows display? var years = parseInt ( totalMonths / 12 ); var months = totalMonths % 12; if ( years == 0 ) { alert ( months + " months."); } else if ( months == 0 ) { alert ( years + " years"); } else { alert ( years + " years, and " + months + " months."); }

Question 1 options:

1 years, and 1 months

1 year, and 1 month

1 years

1 year

Question 2 (1 point)

Which statements are equivalent to the if statements that follow? if (pay >= 500) { tax_rate = 0.3; } if (pay >= 300 && pay < 500) { tax_rate = 0.2; } if ((pay >= 100) && (pay < 300)) { tax_rate = 0.1; }

Question 2 options:

if (pay > 100) { tax_rate = 0.1; } else if (pay > 300) { tax_rate = 0.2; } else if (pay > 500) { tax_rate = 0.3; }

if (pay >= 500) { tax_rate = 0.3; } else if (pay >= 300) { tax_rate = 0.2; } else if (pay >= 100) { tax_rate = 0.1; }

if (pay >= 500) { tax_rate = 0.3; } else { tax_rate = 0.2; } if (pay > 100) { tax_rate = 0.1; }

none of the above are equivalent

Question 3 (1 point)

What is the value of the variable named counter after the code that follows is executed? var percent = 0.54; var isValid = true; var counter = 1; if ((percent > 0.50) && (isValid == true)) { counter += 2; if (isValid == true) { counter++; } else if (percent >= 0.50) { counter += 3; } } else { counter++; }

Question 4 options:

2

3

4

7

Question 5 (1 point)

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 5 options:

0

4

5

6

Question 6 (1 point)

The type of loop that provides for varying the value of an index (or counter) is a

Question 6 options:

while loop

for loop

do-while loop

all of the above

Question 7 (1 point)

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 7 options:

1000

1100

11000

1010

Question 8 (1 point)

What is displayed in the alert dialog box after the following code is executed? var items = 3; for (var i = 1; i <= items; i++) { var result = 1; for (var j = i; j >= 1; j--) { result *= j; } alert("The factorial of " + i + " = " + result); }

Question 8 options:

The factorial of 1 = 1

The factorial of 2 = 4

The factorial of 3 = 6

The factorial of 4 = 24

Question 9(1 point)

What is the value of scores[3] after the following code is executed? var scores = [70, 20, 35, 15]; scores[3] = scores[0] + scores[2];

Question 9 options:

15

105

2

120

Question10 (1 point)

What is displayed in the alert dialog box after the following code is executed? var scores = [70, 20, 35, 15]; scores[scores.length] = 40; alert("The scores array: " + scores);

Question 10 options:

The scores array: 70,20,35,15,40

The scores array: 40

The scores array: 70 20 35 40

The scores array:

Question 11 (1 point)

What is the value of the num_colors variable? var colors = ["red","blue","orange","yellow","green","brown","purple"]; num_colors = colors.length

Question 11 options:

6

7

8

NaN

Question 12 (1 point)

What is the value of the totalsString variable after the following code is executed? var totals = [141.95, 212.95, 411, 10.95]; totals[2] = 312.95; var totalsString = ""; for (var i = 0; i < totals.length; i++) { totalsString += totals[i] + "|"; }

Question 12 options:

141.95|212.95|411|10.95|

141.95|212.95|312.95|10.95|

141.95|212.95|411|312.95|

10.95|

Question 13 (1 point)

What is the value of the average variable after the following code is executed? var sum = 0; var prices = [14, 10, 9, 12, 11, 14, 10, 8]; for( var i = 0; i < prices.length; i++ ) { sum = sum + prices[i]; } var average = sum/prices.length;

Question 13 options:

7.27

6.72

8

11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!