Update descriptions for pad and toDecimalMark
Missing prototypes in the code explanations.
This commit is contained in:
@ -5,7 +5,7 @@ tags: string,beginner
|
|||||||
|
|
||||||
Pads a string on both sides with the specified character, if it's shorter than the specified length.
|
Pads a string on both sides with the specified character, if it's shorter than the specified length.
|
||||||
|
|
||||||
Use `String.padStart()` and `String.padEnd()` to pad both sides of the given string.
|
Use `String.prototype.padStart()` and `String.prototype.padEnd()` to pad both sides of the given string.
|
||||||
Omit the third argument, `char`, to use the whitespace character as the default padding character.
|
Omit the third argument, `char`, to use the whitespace character as the default padding character.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -17,4 +17,4 @@ const pad = (str, length, char = ' ') =>
|
|||||||
pad('cat', 8); // ' cat '
|
pad('cat', 8); // ' cat '
|
||||||
pad(String(42), 6, '0'); // '004200'
|
pad(String(42), 6, '0'); // '004200'
|
||||||
pad('foobar', 3); // 'foobar'
|
pad('foobar', 3); // 'foobar'
|
||||||
```
|
```
|
||||||
|
|||||||
@ -3,7 +3,9 @@ title: toDecimalMark
|
|||||||
tags: utility,math,beginner
|
tags: utility,math,beginner
|
||||||
---
|
---
|
||||||
|
|
||||||
Use `toLocaleString()` to convert a float-point arithmetic to the [Decimal mark](https://en.wikipedia.org/wiki/Decimal_mark) form. It makes a comma separated string from a number.
|
Converts a number to a decimal mark formatted string.
|
||||||
|
|
||||||
|
Use `Number.prototype.toLocaleString()` to convert the numbre to decimal mark format.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const toDecimalMark = num => num.toLocaleString('en-US');
|
const toDecimalMark = num => num.toLocaleString('en-US');
|
||||||
@ -11,4 +13,4 @@ const toDecimalMark = num => num.toLocaleString('en-US');
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
toDecimalMark(12305030388.9087); // "12,305,030,388.909"
|
toDecimalMark(12305030388.9087); // "12,305,030,388.909"
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user