better callingNumberKorean impl

This commit is contained in:
kimpure 2026-05-21 13:34:56 +00:00
parent f1f09cc31a
commit bbc138d6a0
No known key found for this signature in database

View file

@ -8,10 +8,6 @@ export default class CallingNumberKorean {
"", "한", "두", "세", "네", "다섯", "", "한", "두", "세", "네", "다섯",
"여섯", "일곱", "여덟", "아홉", "열", "여섯", "일곱", "여덟", "아홉", "열",
] ]
static FirstDigitSingle = [
"영", "한", "두", "세", "네", "다섯",
"여섯", "일곱", "여덟", "아홉", "열",
]
static canConvert(num: number): boolean { static canConvert(num: number): boolean {
return num < 100 && num >= 0 && Number.isInteger(num) return num < 100 && num >= 0 && Number.isInteger(num)
} }
@ -19,13 +15,15 @@ export default class CallingNumberKorean {
const firstDigit = num % 10; const firstDigit = num % 10;
const secondDigit = Math.floor(num / 10); const secondDigit = Math.floor(num / 10);
if (secondDigit) { let result = (
return (
this.SecondDigit[secondDigit] this.SecondDigit[secondDigit]
+ this.FirstDigit[firstDigit] + this.FirstDigit[firstDigit]
); );
} else {
return this.FirstDigitSingle[firstDigit]; if (!result.length) {
} result = "영"
}
return result;
} }
} }