Jump to content

Sort Strings

From Drywall Wiki
Revision as of 17:45, 7 January 2026 by Jlebeau81 (talk | contribs) (Created page with "<h1>sort words in alphabetical order</h1> // take input const string = prompt('Enter a sentence: '); // converting to an array const words = string.split(' '); // sort the array elements words.sort(); // display the sorted words console.log('The sorted words are:'); for (const element of words) { console.log(element); }")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

sort words in alphabetical order

// take input const string = prompt('Enter a sentence: '); // converting to an array const words = string.split(' '); // sort the array elements words.sort(); // display the sorted words console.log('The sorted words are:'); for (const element of words) {

 console.log(element);

}