Created
January 28, 2017 09:48
-
-
Save SK-CSE/879747cf930892e32e2940081f8c3753 to your computer and use it in GitHub Desktop.
acronym function in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Thank you
Really helped me out, cheers for this
Thank you, it was really useful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
😊