1번 - replace-temp-with-query1
if 문 / 삼항 연산자
discountFactor() {
const basePrice = this.basePrice();
if (basePrice > 1000) {
return 0.95;
} else {
return 0.98;
}
}
discountFactor() {
const basePrice = this.basePrice();
basePrice > 1000 ? 0.95 : 0.98
}
임시변수
discountFactor(파라미터)
2번 - replace-temp-with-query2
아이템 프라이스 코드 차이
//기존
basePrice = this.itemPrice * 2; // basePrice에 두번째 대입
//refactor
price() {
return this.itemPrice * 2;
}
default parameter 2 그외에 값을 받아올수 있게
'스터디일지' 카테고리의 다른 글
[개발 스터디] 23.01.01 (0) | 2023.01.08 |
---|---|
221225 개발 스터디 기록 (0) | 2022.12.31 |