forked from woowacourse/javascript-movie-review
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(MovieRating): 별점 text 및 number 계산해주는 함수 constants > rating 파…
…일로 분리
- Loading branch information
Showing
2 changed files
with
29 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
export const DEFAULT_RATING = 0; | ||
export const MAX_RATING = 5; | ||
|
||
export const getRatingNumber = (rating: number) => { | ||
return rating * 2; | ||
}; | ||
|
||
export const getRatingText = (rating: number) => { | ||
switch (rating) { | ||
case 1: | ||
return "최악이예요"; | ||
case 2: | ||
return "별로예요"; | ||
|
||
case 3: | ||
return "보통이에요"; | ||
|
||
case 4: | ||
return "재미있어요"; | ||
|
||
case 5: | ||
return "명작이에요"; | ||
|
||
default: | ||
return "별점을 매겨보세요"; | ||
} | ||
}; |