Add reverseString
This commit is contained in:
10
README.md
10
README.md
@ -255,7 +255,7 @@ var objectFromPairs = arr =>
|
|||||||
|
|
||||||
### Powerset
|
### Powerset
|
||||||
|
|
||||||
Use `reduce()` combined with `map()` to iterate over elements and combine into an array containing all combinations.
|
Use `reduce()` combined with `map()` to iterate over elements and combine into an array containing all combinations.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var powerset = arr =>
|
var powerset = arr =>
|
||||||
@ -288,6 +288,14 @@ var redirect = (url, asLink = true) =>
|
|||||||
asLink ? window.location.href = url : window.location.replace(url);
|
asLink ? window.location.href = url : window.location.replace(url);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Reverse a string
|
||||||
|
|
||||||
|
Use `reverse()` to reverse order of elements in `destructed` array. Combine elements to get a string using `join('')`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var reverseString = str => [...str].reverse().join('');
|
||||||
|
```
|
||||||
|
|
||||||
### RGB to hexadecimal
|
### RGB to hexadecimal
|
||||||
|
|
||||||
Convert each value to a hexadecimal string, using `toString(16)`, then `padStart(2,'0')` to get a 2-digit hexadecimal value.
|
Convert each value to a hexadecimal string, using `toString(16)`, then `padStart(2,'0')` to get a 2-digit hexadecimal value.
|
||||||
|
|||||||
Reference in New Issue
Block a user