diff --git a/README.md b/README.md index a51507bba..8c87ac7d3 100644 --- a/README.md +++ b/README.md @@ -4178,14 +4178,7 @@ Use the spread operator (`...`) and `Array.reverse()` to reverse the order of th Combine characters to get a string using `String.join('')`. ```js - - - - -const reverseString = str => - [..str] - .reverse() - .join(''); +const reverseString = str => [...str].reverse().join(''); ```
diff --git a/docs/index.html b/docs/index.html index 0c345e92a..4f9c4aef7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -885,14 +885,7 @@ console.log< }; const autoPluralize = pluralize(PLURALS); autoPluralize(2, 'person'); // 'people' -

reverseString

Reverses a string.

Use the spread operator (...) and Array.reverse() to reverse the order of the characters in the string. Combine characters to get a string using String.join('').

-
-
-
-const reverseString = str =>
-  [..str]
-    .reverse()
-    .join('');
+

reverseString

Reverses a string.

Use the spread operator (...) and Array.reverse() to reverse the order of the characters in the string. Combine characters to get a string using String.join('').

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

sortCharactersInString

Alphabetically sorts the characters in a string.

Use the spread operator (...), Array.sort() and String.localeCompare() to sort the characters in str, recombine using String.join('').

const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join('');
 
sortCharactersInString('cabbage'); // 'aabbceg'
diff --git a/snippets/reverseString.md b/snippets/reverseString.md
index 12112f783..3920179a1 100644
--- a/snippets/reverseString.md
+++ b/snippets/reverseString.md
@@ -6,14 +6,7 @@ Use the spread operator (`...`) and `Array.reverse()` to reverse the order of th
 Combine characters to get a string using `String.join('')`.
 
 ```js
-
-
-
-
-const reverseString = str =>
-  [...str]
-    .reverse()
-    .join('');
+const reverseString = str => [...str].reverse().join('');
 ```
 
 ```js