Discounts

discountPercent(isMember, hasCoupon) gives 15, 10, 5 or 0 depending on the combination of club and coupon. Your tests must pass on the correct code and catch the 4 bugs.

Concept: lesson Decision table: every combination

Exercise

/**
 * Discount percentage for an order.
 * - Member with a coupon: 15.
 * - Member without a coupon: 10.
 * - Non-member with a coupon: 5.
 * - Non-member without a coupon: 0.
 * @param {boolean} isMember
 * @param {boolean} hasCoupon
 * @returns {number}
 */
function discountPercent(isMember, hasCoupon)

Your tests

0 of 4 bugs caught

  • Bug 1: hidden
  • Bug 2: hidden
  • Bug 3: hidden
  • Bug 4: hidden