Files
30-seconds-of-code/snippets/reverse-a-string.md
Angelos Chalaris 43f8529cb9 Added samples
2017-12-12 17:50:08 +02:00

10 lines
283 B
Markdown

### Reverse a string
Use array destructuring and `Array.reverse()` to reverse the order of the characters in the string.
Combine characters to get a string using `join('')`.
```js
const reverseString = str => [...str].reverse().join('');
// reverseString('foobar') -> 'raboof'
```