how to sort strings in alphabetical order js code example
Example 1: array sort by alphabetical javascript
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
Example 2: javascript return string in alphabetical order
function alphabet_Soup(str) {
return str.split("").sort().join("");
}
console.log(alphabet_Soup("Python"));
console.log(alphabet_Soup("Exercises"));
//My Solution
function alphaOrder(str) {
return str.split("").sort().join("");
}
console.log(alphaOrder("webdev"))