Created
November 23, 2015 02:12
-
-
Save jihunleekr/d175222e68f296470898 to your computer and use it in GitHub Desktop.
숫자를 한글발음대로 표기
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
/** | |
* 숫자를 한글발음대로 표기 | |
* 구글 스프레드시트에서는 아래의 함수가 없어서 구현함. | |
* 한글만 지원. (원래 함수는 한자 등의 다양한 타입을 지원함) | |
*/ | |
function numberstring(num) { | |
var namesInSeat = ['', '일', '이', '삼', '사', '오', '육', '칠', '팔', '구'], | |
namesInSeats = ['', '십', '백', '천'], | |
namesInFourSeat = ['', '만', '억', '조'], | |
numArr = num.toString().split('').reverse(), | |
numStr = '', | |
i | |
for (i = numArr.length - 1; i >= 0; i--) { | |
if (numArr[i] > 0) { | |
numStr += namesInSeat[numArr[i]]; | |
numStr += namesInSeats[i % 4]; | |
} | |
if (i % 4 == 0) { | |
numStr += namesInFourSeat[parseInt(i / 4)]; | |
} | |
} | |
return numStr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment