"capitalize first letter of all word typescript" Code Answer's

You're definitely familiar with the best coding language Javascript that developers use to develop their projects and they get all their queries like "capitalize first letter of all word typescript" answered properly. Developers are finding an appropriate answer about capitalize first letter of all word typescript related to the Javascript coding language. By visiting this online portal developers get answers concerning Javascript codes question like capitalize first letter of all word typescript. Enter your desired code related query in the search bar and get every piece of information about Javascript code related question on capitalize first letter of all word typescript. 

javascript capitalize words

By GrepperGrepper on Jul 22, 2019
//capitalize only the first letter of the string. 
function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}
//capitalize all words of a string. 
function capitalizeWords(string) {
    return string.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};

Add Comment

65

javascript capitalize first letter of each word

By AnkurAnkur on May 01, 2020
function titleCase(str) {
   var splitStr = str.toLowerCase().split(' ');
   for (var i = 0; i < splitStr.length; i++) {
       // You do not need to check if i is larger than splitStr length, as your for does that for you
       // Assign it back to the array
       splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);     
   }
   // Directly return the joined string
   return splitStr.join(' '); 
}

document.write(titleCase("I'm a little tea pot"));

Source: stackoverflow.com

Add Comment

2

capitalize first letter of all word typescript

By Nish ShanNish Shan on Nov 18, 2020
//Altered, "capitalize all words of a string" (javascript by Grepper on Jul 22 2019) answer to compatible with TypeScript

var myString = 'abcd abcd';

capitalizeWords(text){
  return text.replace(/(?:^|\s)\S/g,(res)=>{ return res.toUpperCase();})
};

console.log(capitalizeWords(myString));

//result = "Abcd Abcd" 

Add Comment

0

All those coders who are working on the Javascript based application and are stuck on capitalize first letter of all word typescript can get a collection of related answers to their query. Programmers need to enter their query on capitalize first letter of all word typescript related to Javascript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about capitalize first letter of all word typescript for the programmers working on Javascript code while coding their module. Coders are also allowed to rectify already present answers of capitalize first letter of all word typescript while working on the Javascript language code. Developers can add up suggestions if they deem fit any other answer relating to "capitalize first letter of all word typescript". Visit this developer's friendly online web community, CodeProZone, and get your queries like capitalize first letter of all word typescript resolved professionally and stay updated to the latest Javascript updates. 

Javascript answers related to "capitalize first letter of all word typescript"

View All Javascript queries

Javascript queries related to "capitalize first letter of all word typescript"

capitalize first letter of all word typescript javascript first letter uppercase push at first index typescript regex to get part of word nodejs extract string from string javascript based on word replace word in array js typescript round to 2 decimals how to create dynamic classes in tailwind typescript react next js typescript module.exports equivalent typescript equalsignorecase typescript react-hook-form typescript copy array typescript how to get last element of array in typescript typescript check if object has key typescript random int typescript string contains tuple in typescript if shorthand typescript typescript double question mark typescript array find template string in typescript filter max value from array typescript express validator typescript how to check whether a string contains a substring in typescript online find typescript module.exports in typescript boolean to string typescript reverse string in typescript typescript convert color to rgb how to get the median in typescript hex to rgb typescript typescript map array typescript foreach async await filter duplicate value in array of object typescript typescript random number typescript delete value from map typescript react switch case component typescript splice how to remove elements from object in typescript trim undefined keys from object typescript typescript last index of array typescript clear array typescript absolute value check if substring in string typescript typescript array insert how to use variable as object key in typescript typescript if string is null or empty typescript read url search params fibonacci counter in typescript string to number typescript typescript settimeout angular get first element ngfor react useeffect not on first render react useEffect prevent first time javascript remove first character from string Return the first element of the array javascript how to not execute useEffect when loading the page first time es6 get first and last element of array angular formarray remove all react replace all line breaks with br react router catch all 404 watchman watch-del-all, and react-native start --reset-cache how to get all elements with same class in javascript dropzone on success all files check if all elements in array are true javascript how to add up all the numbers in between 0 and that number sum all elements in array javascript cypress run all files in folder with javascript, which label catches all values except those specified in a switch statement? jsdoc doesn't see all folders laravel modify all json responses how add all json files to one json file in command prompt how to remove all element from formarray how do i remove all vowels from a string in javascript and return the result To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. npm update all packages

Browse Other Code Languages

CodeProZone