Skip to content

Instantly share code, notes, and snippets.

@codedcontainer
Created October 16, 2017 17:42
Show Gist options
  • Save codedcontainer/f9f1c6cb3759f57834d804367fce171f to your computer and use it in GitHub Desktop.
Save codedcontainer/f9f1c6cb3759f57834d804367fce171f to your computer and use it in GitHub Desktop.
Make every word in a sentence capitalized
function formatReportTitle(objectKeys){
var formattedReportArray = [];
for (a = 0; a <= objectKeys.length -1; a++){ //loop through array of report types/object keys
var splitString = objectKeys[a].split("_"); //slpit the array by "_"
//loop through each string item
for (var b = 0; b <= splitString.length -1; b++ ){
splitString[b] = splitString[b].split(''); //splits string into array of letters
splitString[b][0] = splitString[b][0].toUpperCase(); //makes first letter capitalizes
splitString[b]= splitString[b].join(''); //converts array of letter back to word
}
formattedReportArray.push(splitString.join(" ")); //converts words into a sentance
}
return formattedReportArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment