Generate an Acronym from a Phrase

You’re working on a project that involves creating abbreviations for different phrases. To make the names easier to remember, you decide to generate an acronym for each phrase by combining the first letters of every word. This acronym will help people recall complex terms or long names quickly.

Instructions:

  • Write a function named generateAcronym that takes a parameter called phrase, which contains a string of words separated by single spaces.

  • The function should construct an acronym from the phrase by taking the first letter of each word and capitalizing it.

  • Return the resulting acronym as a string.

Example 1

Input: generateAcronym("Portable Network Graphics");
Output: 'PNG'

Example 2

Input: generateAcronym("National Aeronautics and Space Administration");
Output: 'NASA'

Example 3

Input: generateAcronym("Self Contained Underwater Breathing Apparatus");
Output: 'SCUBA'

Are you stuck on this problem?

Get detailed, step-by-step solution and improve your JavaScript skills.

  • Detailed Explanation: Each solution comes with a comprehensive explanation, helping you understand the logic and concepts thoroughly.
  • Learn to Write Better Code: Even if you have written the code, discover ways to improve it and adopt best practices.
  • Save Time: Don’t waste hours struggling—get the solution and learn efficiently.
  • Lifetime Access: Get access to lifetime solutions for all problems available
Get the Solution

" I struggled with this problem for hours, but the solution provided here was clear and easy to follow. It helped me understand where I went wrong and improved my coding skills significantly." - Jane D.

If you're not satisfied, I offer a 7-day money-back guarantee.