JavaScript Question 11 (1 point) After the code that follows is executed, what i
ID: 3910733 • Letter: J
Question
JavaScript
Question 11 (1 point)
After the code that follows is executed, what is the value of discountAmount?
var discountAmount;
var orderTotal = 200;
if (orderTotal > 200) {
discountAmount = orderTotal * .3;
} else if (orderTotal > 100) {
discountAmount = orderTotal * .2;
} else {
discountAmount = orderTotal * .1;
}
Question 11 options:
0.0
20.0
40.0
60.0
Save
Question 12 (1 point)
Assume that the variables named entry and number have starting values of 9 and 3 respectively. What is the value of entry after the following statements are executed?
if ((entry > 9) || (entry/number == 3)) {
entry--;
} else if (entry == 9) {
entry++;
} else {
entry = 3;
}
Question 12 options:
3
8
9
10
Save
Question 13 (1 point)
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 13 options:
1 years, and 1 months
1 year, and 1 month
1 years
1 year
Save
Question 14 (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 14 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
Save
Question 15 (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 15 options:
2
3
4
7
Save
0.0
20.0
40.0
60.0
Explanation / Answer
11.
var orderTotal = 200;
if (orderTotal > 200) { // 200 >200 false
discountAmount = orderTotal * .3;
} else if (orderTotal > 100) { // 100 >200 false
discountAmount = orderTotal * .2; // discountAmount = 200 * .2 = 40
Option 3
12.
entry=9 and number =3
9/3 == 3
if ((entry > 9) || (entry/number == 3)) { // (9 > 9 => false || 3 == 3 =>true) since use OR logic it is true
{
entry--; // entry = 9-1 =8
}
Option 2
13.
totalMonths = 13
var years = parseInt ( totalMonths / 12 ); // 13/12 = 1 (since int data type)
var months = totalMonths % 12; // 13%12 = 1
if ( years == 0 ) { // False
else if ( months == 0 ) // False
else {
alert ( years + " years, and " + months + " months."); // It print 1 years, and 1 months
}
Option 1
14.
if (pay >= 500) { // more than 500
tax_rate = 0.3;
} else if (pay >= 300) { // 300 - 499
tax_rate = 0.2;
} else if (pay >= 100) { // 100-299
tax_rate = 0.1;
}
Option 2
15.
var percent = 0.54;
var isValid = true;
var counter = 1;
if ((percent > 0.50) && (isValid == true)) { ((0.54 > 0.50) =>True and (true== true)=>True) =>True
counter += 2; // counter = 1+2 = 3
if (isValid == true) { // (true== true)=>True
counter++; counter = 3+1 = 4
}
Option 3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.