Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

title case javascript

function titleCase(str) {
    return str
        .split(' ')
        .map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase())
        .join(' ');
}
console.log(titleCase("I'm a little tea pot")); // I'm A Little tea Pot
Comment

Title Case a Sentence-Javascript

function titleCase(str) {
  return str.toLowerCase().replace(/(^|s)S/g, L => L.toUpperCase());
}
Comment

string to title case javascript

function titleCase(sentence) {
  let sentence = string.toLowerCase().split(" ");
  for (let i = 0; i < sentence.length; i++) {
    sentence[i] = sentence[i][0].toUpperCase() + sentence[i].slice(1);
  }
  
  return sentence.join(" ");
}
Comment

how to convert string to reverse title case in javascript

const reverseTitleCase = (string) => {
  const newText = string
    .toLowerCase()
    .split(" ")
    .map(function(item) {
      return item.slice(0, -1) + item.slice(-1).toUpperCase();
    })
    .join(" ");
  
  return newText;
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: console.log javascript 
Javascript :: use regex to get urls from string 
Javascript :: bootstrap multiselect change value 
Javascript :: sort a dictionary by value in javascript 
Javascript :: js close window 
Javascript :: javascript convert string to number or integer 
Javascript :: how to loop and add number in fuction for javascript 
Javascript :: autocomplete react vscode 
Javascript :: js string array convert to int 
Javascript :: ciclo for javascript 
Javascript :: eslint unexpected console statement 
Javascript :: javascript date to string format 
Javascript :: how to get custom attribute value in react 
Javascript :: javascript get random integer in given range 
Javascript :: for loop infinite javascript 
Javascript :: javascript split string only on first instance of specified character 
Javascript :: mongoose generate objectid 
Javascript :: redux useselector 
Javascript :: convert fetch data to json 
Javascript :: set css variable from javascript 
Javascript :: nestjs return error response 
Javascript :: image preview using js 
Javascript :: componentdidupdate in hooks 
Javascript :: expressjs swagger yaml 
Javascript :: try catch in node js 
Javascript :: js select element inside of div 
Javascript :: how to pretty formatjson value on terminal ruby 
Javascript :: lodash remove undefined values from array 
Javascript :: async storage get item 
Javascript :: how to run a function when the window is closing javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =