Skip to content

Commit

Permalink
Added format number in JS
Browse files Browse the repository at this point in the history
  • Loading branch information
piyukore06 committed Jul 30, 2020
1 parent 2b6b92b commit 3d16d64
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions snippets/formatNumber.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: formatNumber
tags: string,math,beginner
---

Returns a number using the local number format order.

Use `Number.prototype.toLocaleString()` to convert a number to using the local number format separators.

```js
const formatNumber = number => number.toLocaleString();
```

```js
formatNumber(123456); // '123,456' in `en-US`
formatNumber(15675436903); // '15.675.436.903' in `de-DE`
```

0 comments on commit 3d16d64

Please sign in to comment.