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(' / ');
}

0 comments :
Post a Comment