Currently, my focus is on extracting the initial letter of each word in order to create an acronym. I have set up an array where all the capitalized words are stored, and now I need a way to extract those specific characters.
To achieve this, I initially utilized the reduce()
method on the array to isolate the capital letters. However, my goal now is to generate acronyms consisting of varying numbers of capital letters.
var words = ["In", "American", "Broadcast", "Company"];
var output = words.reduce((acronym, word) => {
acronym += word.charAt(0);
return acronym;
}, "");
While this code snippet results in IABC
, the actual correct acronym should be ABC
. Hence, I am contemplating whether it is possible to iterate through and obtain C, BC, ABC, IABC
before ultimately arriving at the accurate acronym ABC
.