Travis build: 1742

This commit is contained in:
30secondsofcode
2018-02-26 11:54:18 +00:00
parent ae20242b56
commit 543ceb09cb
2 changed files with 33 additions and 1 deletions

View File

@ -377,6 +377,7 @@ average(1, 2, 3);
* [`isLowerCase`](#islowercase) * [`isLowerCase`](#islowercase)
* [`isUpperCase`](#isuppercase) * [`isUpperCase`](#isuppercase)
* [`mask`](#mask) * [`mask`](#mask)
* [`pad`](#pad)
* [`palindrome`](#palindrome) * [`palindrome`](#palindrome)
* [`pluralize`](#pluralize) * [`pluralize`](#pluralize)
* [`removeNonASCII`](#removenonascii) * [`removeNonASCII`](#removenonascii)
@ -6939,6 +6940,32 @@ mask(1234567890, -4, '$'); // '$$$$567890'
<br>[⬆ Back to top](#table-of-contents) <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 ### palindrome
Returns `true` if the given string is a palindrome, `false` otherwise. Returns `true` if the given string is a palindrome, `false` otherwise.

File diff suppressed because one or more lines are too long