Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]:numberToHangul의 숫자 변환 오류 #311

Closed
wet6123 opened this issue Jan 5, 2025 · 0 comments · Fixed by #314
Closed

[Bug]:numberToHangul의 숫자 변환 오류 #311

wet6123 opened this issue Jan 5, 2025 · 0 comments · Fixed by #314
Labels
bug Something isn't working

Comments

@wet6123
Copy link
Contributor

wet6123 commented Jan 5, 2025

Bug description

numberToHangul에서 억, 조 등의 만보다 큰 단위를 가진 숫자를 변형할 때 불필요한 단위가 붙어서 출력됩니다.

Expected behavior

해당하는 단위의 값이 0인 경우 단위를 출력하지 않습니다.

To Reproduce

expect(numberToHangul(100_000_000)).toBe('일억');       //but 일억만
expect(numberToHangul(1_000_000_000_000)).toBe('일조'); //but 일조억만

Possible Solution

해당 단위에 값이 있는 경우에만 단위를 붙여서 출력하도록 수정합니다.

// 현재:
koreanParts.unshift(`${numberToKoreanUpToThousand(Number(currentPart))}${HANGUL_DIGITS[placeIndex]}`);

// 수정:
const koreanNumber = numberToKoreanUpToThousand(Number(currentPart));
if (koreanNumber !== '') {
  // 값이 있을 때만 단위를 붙임
  koreanParts.unshift(`${koreanNumber}${HANGUL_DIGITS[placeIndex]}`);
}

etc.

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant