Question: Build Acronyms ( filename: buildacronyms.html) Write JavaScript code that prompts the user to enter a phrase. Then, using a while loop or a do-while loop,
Build Acronyms (filename: buildacronyms.html)
Write JavaScript code that prompts the user to enter a phrase. Then, using a while loop or a do-while loop, turn the phrase into an acronym (strictly speaking an initialism) by building a new string that contains the first letter of each word from the user phrase entered. Every letter in the resulting string should be capitalized (use the toUpperCase function). Display the acronym in a message box.
Before building the acronym, use the trim() function to remove any spaces that the user might have added before or after the phrase.
Note: There may be more than one space between the words
The following are some examples:
"Hello world " becomes HW
" Vancouver" becomes V
"Three letter acronym " becomes TLA
IMPORTANT: You must use a loop to check every character of the input and build the acronym. You will not receive credit if your solution does not do so.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
