UNPKG

@jk-core/components

Version:
17 lines (13 loc) 404 B
const formatMoney = (value?: number) => { if (value === undefined) return '- 원'; let money = value; const units = ['원', '만원', '억원', '조원', '경원', '해원']; let unitIndex = 0; while (money >= 10000 && unitIndex < units.length - 1) { money /= 10000; unitIndex += 1; } money = Math.round(money); return [money, units[unitIndex]]; }; export default formatMoney;