Answers for "javascript functions to change case to proper case"

7

Javascript switch case code format

switch(type) {
	case "SomeString":
		// Functionality
		break;
	case "OtherString":
		// Functionality
		break;
	default:
		// Functionality
		break;
}
Posted by: Guest on May-25-2020
-1

javascript string proper case

function toTitleCase(str) {
  return str.replace(
    /\w\S*/g,
    function(txt) {
      return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    }
  );
}
// example
toTitleCase("the pains and gains of self study");
// "The Pains And Gains Of Self Study"
Posted by: Guest on December-10-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language