function getFormattedText() {
var formattedString= capitalizedTextAfterBackslash("Red spruce / balsam fir/tamarack");
alert(formattedString);
};
function capitalizedTextAfterBackslash(str){
var temp= str.split("\/");
for(var i=0; i<temp.length; i++) {
temp[i] = temp[i].trim();
temp[i] = temp[i].substr(0,1).toUpperCase() + temp[i].substr(1,temp[i].length-1);
}
return temp.join(' / ');
}
Thursday, August 20, 2015
Capitalize each word after forward slash in Java Script : Code snippet
Subscribe to:
Posts
(
Atom
)