Travis build: 1742
This commit is contained in:
27
README.md
27
README.md
@ -377,6 +377,7 @@ average(1, 2, 3);
|
||||
* [`isLowerCase`](#islowercase)
|
||||
* [`isUpperCase`](#isuppercase)
|
||||
* [`mask`](#mask)
|
||||
* [`pad`](#pad)
|
||||
* [`palindrome`](#palindrome)
|
||||
* [`pluralize`](#pluralize)
|
||||
* [`removeNonASCII`](#removenonascii)
|
||||
@ -6939,6 +6940,32 @@ mask(1234567890, -4, '$'); // '$$$$567890'
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### pad
|
||||
|
||||
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.
|
||||
Omit the third argument, `char`, to use the whitespace character as the default padding character.
|
||||
|
||||
```js
|
||||
const pad = (str, length, char = ' ') =>
|
||||
str.padStart((str.length + length) / 2, char).padEnd(length, char);
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
pad('cat', 8); // ' cat '
|
||||
pad(String(42), 6, '0'); // '004200'
|
||||
pad('foobar', 3); // 'foobar'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### palindrome
|
||||
|
||||
Returns `true` if the given string is a palindrome, `false` otherwise.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user