Add reverseString

This commit is contained in:
Stefan Feješ
2017-12-12 07:57:02 +01:00
parent b4781a478d
commit 6119b2566c

View File

@ -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.