Skip to content

Instantly share code, notes, and snippets.

@SK-CSE
Created January 28, 2017 09:48
Show Gist options
  • Save SK-CSE/879747cf930892e32e2940081f8c3753 to your computer and use it in GitHub Desktop.
Save SK-CSE/879747cf930892e32e2940081f8c3753 to your computer and use it in GitHub Desktop.
acronym function in javascript
function firstLetter(word) {
return word[0];
};
function getAcronym(str){
var words = str.split(" "); // ["for","your","information"]
var acr = words.map(firstLetter); // ["f","y","i"]
return acr.join("").toUpperCase();
};
var str = "for your information";
var acronym = getAcronym(str);
console.log(acronym);
@bmeier0689
Copy link

Really helped me out, cheers for this

@selakkkkk
Copy link

Thank you, it was really useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment