Acronym Generator - Problem
Generate an acronym from a given phrase by taking the first letter of each word and converting it to uppercase.
For example, 'Portable Network Graphics' becomes 'PNG'.
Rules:
- Split the phrase into words by spaces
- Take the first character of each word
- Convert all letters to uppercase
- Join them together without spaces
Input & Output
Example 1 — Basic Phrase
$
Input:
phrase = "Portable Network Graphics"
›
Output:
"PNG"
💡 Note:
Take first letter of each word: 'P' from Portable, 'N' from Network, 'G' from Graphics, result is 'PNG'
Example 2 — Single Word
$
Input:
phrase = "Hello"
›
Output:
"H"
💡 Note:
Only one word 'Hello', so acronym is just 'H'
Example 3 — Multiple Spaces
$
Input:
phrase = "World Wide Web"
›
Output:
"WWW"
💡 Note:
Extra spaces are ignored, words are 'World', 'Wide', 'Web', acronym is 'WWW'
Constraints
- 1 ≤ phrase.length ≤ 1000
- phrase consists of letters and spaces
- phrase contains at least one letter
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code