Files
30-seconds-of-code/snippets/reverse-string.md
Stefan Feješ b848906fe5 fix naming
2017-12-17 15:41:31 +01:00

283 B

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('').

const reverseString = str => [...str].reverse().join('');
// reverseString('foobar') -> 'raboof'