Skip to content

Commit

Permalink
♻ 3자리마다 ,삽입 util 함수 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrevile committed Apr 27, 2022
1 parent ed1d796 commit 41a2145
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils/numberWithCommas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const numberWithCommas = (num: number): string => {
let parts: number | string[] = num;
parts = parts.toString().split('.');
return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',') + (parts[1] ? '.' + parts[1] : '');
};

//숫자를 넣으면 3자리마다 , 찍히고 소수점 2자리 까지 표현

0 comments on commit 41a2145

Please sign in to comment.