Skip to content

Instantly share code, notes, and snippets.

@twlca
Created October 15, 2016 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twlca/2b8f56f440f8254d5cda85fa7a103813 to your computer and use it in GitHub Desktop.
Save twlca/2b8f56f440f8254d5cda85fa7a103813 to your computer and use it in GitHub Desktop.
var digits = '0123456789'; // 阿拉伯數字
var small_chinese_digits = '〇一二三四五六七八九'; // 中文小寫數字
var capital_chinese_digits = '零壹貮參肆伍陸㭍捌玖拾佰仟萬億兆'; // 中文大寫數字,應用侷限在金融,例如支票、匯款單、存款/提款單等
// 由阿拉伯數字轉換成小寫中文數字
var year = '106';
year.split('').map( function( item ) {
return small_chinese_digits.split('')[item];
}).join('');
// 回傳 "一〇五"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment