Skip to content

Instantly share code, notes, and snippets.

@GeekaholicLin
Created August 29, 2016 15:50
Show Gist options
  • Save GeekaholicLin/b7b77972172fe294406bf67f90b096fb to your computer and use it in GitHub Desktop.
Save GeekaholicLin/b7b77972172fe294406bf67f90b096fb to your computer and use it in GitHub Desktop.
transfer the title of all the worlds in the sentence to uppercase
function titleCase(str) {
  var str1 = str.toLowerCase().replace(/\b(\w|')+\b/g, function(str){
  return str.substring(0,1).toUpperCase()+str.substring(1);
  }
  );
  return str1;
}
/*
  /\b(\w|')+\b/g
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment