I'm working on extracting the first letter of the word to form an acronym. I have an array to store all the Capticalized words and what I need to do is to get those Capitalized characters.
I used array reduce() method to get the capital letter. But I would like to get all the acronyms formed by different numbers of the capital letter.
var words = ["In", "American", "Broadcast", "Company"];
var output = words.reduce((acronym, word) => {
acronym += word.charAt(0);
return acronym;
}, "");
This will produce an output IABC, but we know the correct acronym is ABC, so I am thinking can we get C, BC, ABC, IABC in an iteration and then get the correct acronym ABC?