forked from Chalarangelo/30-seconds-of-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b6b92b
commit 3d16d64
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
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
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` | ||
``` |