better callingNumberKorean impl
This commit is contained in:
parent
f1f09cc31a
commit
bbc138d6a0
1 changed files with 9 additions and 11 deletions
|
|
@ -8,10 +8,6 @@ export default class CallingNumberKorean {
|
|||
"", "한", "두", "세", "네", "다섯",
|
||||
"여섯", "일곱", "여덟", "아홉", "열",
|
||||
]
|
||||
static FirstDigitSingle = [
|
||||
"영", "한", "두", "세", "네", "다섯",
|
||||
"여섯", "일곱", "여덟", "아홉", "열",
|
||||
]
|
||||
static canConvert(num: number): boolean {
|
||||
return num < 100 && num >= 0 && Number.isInteger(num)
|
||||
}
|
||||
|
|
@ -19,13 +15,15 @@ export default class CallingNumberKorean {
|
|||
const firstDigit = num % 10;
|
||||
const secondDigit = Math.floor(num / 10);
|
||||
|
||||
if (secondDigit) {
|
||||
return (
|
||||
let result = (
|
||||
this.SecondDigit[secondDigit]
|
||||
+ this.FirstDigit[firstDigit]
|
||||
);
|
||||
} else {
|
||||
return this.FirstDigitSingle[firstDigit];
|
||||
}
|
||||
|
||||
if (!result.length) {
|
||||
result = "영"
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue