Add reverseString

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

View File

@ -288,6 +288,14 @@ var redirect = (url, asLink = true) =>
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
Convert each value to a hexadecimal string, using `toString(16)`, then `padStart(2,'0')` to get a 2-digit hexadecimal value.