diff --git a/README.md b/README.md index 9b166f0f6..8152f1c7c 100644 --- a/README.md +++ b/README.md @@ -255,7 +255,7 @@ var objectFromPairs = arr => ### 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 var powerset = arr => @@ -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.