How would you go around to collect the first letter of each word in a string, as in to receive an abbreviation?
Input: "Java Script Object
"Java Script Object
How about this:
var str = "", abbr = ""; str = "Java Script Object Notation"; str = str.split(' '); for (i = 0; i < str.length; i++) { abbr += str[i].substr(0,1); } alert(abbr);
Working Example.