172k views
3 votes
JavaScript

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;
}
a) 0.0
b) 20.0
c) 40.0
d) 60.0

User Julio
by
4.5k points

1 Answer

2 votes

Answer:

C. 40

Step-by-step explanation:

The code uses IF and ELSE statements to carry execute a block of code if any of the statements hold true

OrderTotal here is greater than 100, and this allows the second IF ELSE block to be executed.

The code to be executed is discountAmount = OrderTotal * 0.2

This will be discountAmount = 200 *0.2

therefore, discountAmount = 40.

User Anik Barua
by
4.7k points