Skip to content

Commit

Permalink
♻️ 변수 재할당 방지
Browse files Browse the repository at this point in the history
- 불변성 유지 : let을 const로 변경
(const로 선언하고 싶었는데 왜 안되는지 싶었는데 영우님의 도움으로 해결.. 이제야 let과 const를 이해했다!)
  • Loading branch information
pitangland committed Jan 19, 2025
1 parent 37950e2 commit a538508
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/refactoring/models/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export const applyCoupon = (totalAfterDiscount: number, selectedCoupon: Coupon |
// 장바구니 전체 금액 및 할인 계산
export const calculateCartTotal = (cart: CartItem[], selectedCoupon: Coupon | null) => {
const totalBeforeDiscount = calculateTotalBeforeDiscount(cart);
let totalAfterDiscount = calculateTotalAfterDiscount(cart);
// let totalAfterDiscount = calculateTotalAfterDiscount(cart);

// 쿠폰 적용
totalAfterDiscount = applyCoupon(totalAfterDiscount, selectedCoupon);
const totalAfterDiscount = applyCoupon(calculateTotalAfterDiscount(cart), selectedCoupon);

// 총 할인 금액 계산
let totalDiscount = totalBeforeDiscount - totalAfterDiscount;
Expand Down

0 comments on commit a538508

Please sign in to comment.