Skip to content

Commit 12720b6

Browse files
author
YOUNGGEUN OH
committed
1.4 추출한 amountFor함수 내 매개변수, 변수명을 명확히 변경
1 parent 19bfa0c commit 12720b6

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎index.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ function statement(invoice, plays) {
3131

3232

3333
// 중첩 함수(nested function)로 함수 추출
34-
function amountFor(perf, play) {
35-
let thisAmount = 0;
34+
function amountFor(aPerformance, play) {
35+
let result = 0;
3636

3737
switch (play.type) {
3838
case "tragedy": // 비극
39-
thisAmount = 40000;
40-
if (perf.audience > 30) {
41-
thisAmount += 1000 * (perf.audience - 30);
39+
result = 40000;
40+
if (aPerformance.audience > 30) {
41+
result += 1000 * (aPerformance.audience - 30);
4242
}
4343
break;
4444
case "comedy": // 희극
45-
thisAmount = 30000;
46-
if (perf.audience > 20) {
47-
thisAmount += 10000 + 500 * (perf.audience - 20);
45+
result = 30000;
46+
if (aPerformance.audience > 20) {
47+
result += 10000 + 500 * (aPerformance.audience - 20);
4848
}
49-
thisAmount += 300 * perf.audience;
49+
result += 300 * aPerformance.audience;
5050
break;
5151
default:
5252
throw new Error(`알 수 없는 장르 : ${play.type}`);
5353
}
5454

55-
return thisAmount;
55+
return result;
5656
}
5757
}
5858

0 commit comments

Comments
 (0)