변수 추출

1 개요[ | ]

extract variable
변수 추출
function getTotal() {
  return $order->quantity * $order->itemPrice -
    max(0, $order->quantity - 500) * $order->itemPrice * 0.05 +
    min($order->quantity * $order->itemPrice * 0.1, 100);
}
function getTotal() {
  $basePrice = $order->quantity * $order->itemPrice;
  $quantityDiscount = max(0, $order->quantity - 500) * $order->itemPrice * 0.05;
  $shipping = min($basePrice * 0.1, 100);
  return $basePrice - $quantityDiscount + $shipping;
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}