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

PREVIOUS NEXT
Code Example
Javascript :: font weight react native 
Javascript :: open page in new tab using jquery 
Javascript :: fontawesome in next js 
Javascript :: js add string to beginning of string 
Javascript :: select onchange pass option value in angular 6 
Javascript :: removing duplicates in array javascript 
Javascript :: js object random key 
Javascript :: javascript through array 
Javascript :: how to set view engine in express 
Javascript :: check given path is valid or not in nodejs 
Javascript :: on page fully loaded jquery 
Javascript :: local storage javascript object 
Javascript :: nodejs to exe 
Javascript :: If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues. 
Javascript :: add array to localstorage 
Javascript :: get link js 
Javascript :: javascript hasownproperty 
Javascript :: js promise all return json array 
Javascript :: aos library animation angular 
Javascript :: jquery on blur 
Javascript :: fetch then then return value 
Javascript :: how to open html file with javascript 
Javascript :: get select option selected text jquery 
Javascript :: Codewars Beginner - Reduce but Grow 
Javascript :: jquery url change 
Javascript :: jquery change picture source 
Javascript :: reversing an array in js 
Javascript :: open html file in browser using package.json 
Javascript :: react native center text vertically full screen 
Javascript :: fizzbuzz js 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =