logo

Crowdly

Browser

Додати до Chrome

You have the following code: return order.quantity * order.itemPrice -    ...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

You have

the following code:

return order.quantity * order.itemPrice -

      Math.max(0, order.quantity - 500) *

      order.itemPrice * 0.05 +

      Math.min(order.quantity * order.itemPrice * 0.1, 100);

You

refactor it so that it becomes:

const basePrice = order.quantity * order.itemPrice;

const quantityDiscount = Math.max(0, order.quantity - 500) * order.itemPrice * 0.05;

const shipping = Math.min(basePrice * 0.1, 100);

return basePrice - quantityDiscount + shipping;

What type of refactoring is this?

0%
100%
0%
0%
0%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.conncoll.edu?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome