js alphabetical sort of 2 strings code example
Example 1: 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"));
function alphaOrder(str) {
return str.split("").sort().join("");
}
console.log(alphaOrder("webdev"))
Example 2: javascript compare and sort strings alphabetically
function sortString(str){
var arr = str.split('');
var sorted = arr.sort();
return sorted.join('');
}Copy