Skip to content

Commit 1b7fffd

Browse files
committed
10 - Alphabet Soup.js
1 parent 5f2bd37 commit 1b7fffd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

10 - Alphabet Soup.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Step By Step
2+
function AlphabetSoup (str) {
3+
// Use .split to turn the string into an array...
4+
str = str.split('');
5+
6+
// .sort to alphabatize the new array...
7+
str = str.sort();
8+
9+
// and .join to turn it back into a string.
10+
str = str.join('');
11+
12+
// Finally, we return our answer.
13+
return str;
14+
}
15+
16+
// With Chaining
17+
function AlphabetSoup (str) {
18+
return str.split('').sort().join('');
19+
}

0 commit comments

Comments
 (0)