javascript capitalize first letter of each word
JavaScript
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"));//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(); });
};
Also in JavaScript:
- Title
- draw rectangle on javascript canvas
- Category
- JavaScript
- Title
- how get a json object from an api in javascript
- Category
- JavaScript
- Title
- add table row jQuery
- Category
- JavaScript
- Title
- how to delete element in list javascript
- Category
- JavaScript
- Title
- Javascript clear canvas
- Category
- JavaScript
- Title
- convert string with dot or comma as decimal separator to number in javascript
- Category
- JavaScript
- Title
- get value onChange from mat-select angular
- Category
- JavaScript
- Title
- google script get name of google form
- Category
- JavaScript
- Title
- javascript array concat spread operator
- Category
- JavaScript
- Title
- how to delete an element of an array in javascript
- Category
- JavaScript
- Title
- console trace js
- Category
- JavaScript
- Title
- bookshelf insert multiple rows
- Category
- JavaScript
- Title
- bootstrap modal remove gray background
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- javascript base64 encode
- Category
- JavaScript
- Title
- how to create a list in javascript
- Category
- JavaScript
- Title
- add and remove class in jquery
- Category
- JavaScript
- Title
- count number of times an element is occuring in an array in javascript
- Category
- JavaScript
- Title
- javascript check if array is empty
- Category
- JavaScript
- Title
- arrow function javascript ie11
- Category
- JavaScript
- Title
- array map javascript mozilla
- Category
- JavaScript
- Title
- clear input field javascript
- Category
- JavaScript
- Title
- empty a select input using js
- Category
- JavaScript
- Title
- how to add onclick event in javascript
- Category
- JavaScript
- Title
- add firebase angular
- Category
- JavaScript
- Title
- const{}=
- Category
- JavaScript
- Title
- copy to clipboard javascript
- Category
- JavaScript
- Title
- Angularjs datetime
- Category
- JavaScript
- Title
- bind in javascript
- Category
- JavaScript
- Title
- get browser timezone javascript
- Category
- JavaScript
- Title
- includes()
- Category
- JavaScript
- Title
- html get elements by class
- Category
- JavaScript
- Title
- clear scene\
- Category
- JavaScript
- Title
- how to attach javascript to html
- Category
- JavaScript
- Title
- convert json to csv npm
- Category
- JavaScript
- Title
- can we add new state property using setstate in react
- Category
- JavaScript
- Title
- ajax open a request
- Category
- JavaScript
- Title
- ERROR in ./src/app/pages/auth/auth.module.ngfactory.js Module not found: Error: Can't resolve '@angular/material/core/index'
- Category
- JavaScript
- Title
- how to get data in json format in javascript
- Category
- JavaScript
- Title
- For-each over an array in JavaScript
- Category
- JavaScript
- Title
- fonction fleche javascript
- Category
- JavaScript
- Title
- export default react
- Category
- JavaScript
- Title
- how to copy to clipboard in react js
- Category
- JavaScript
- Title
- Javascript change element class
- Category
- JavaScript
- Title
- date picker javascript not working
- Category
- JavaScript
- Title
- bootstrap datepicker js cdn
- Category
- JavaScript
- Title
- do more than one thing at start of or loop javascript
- Category
- JavaScript
- Title
- google maps api javascript
- Category
- JavaScript
- Title
- how to call action from another module vuex
- Category
- JavaScript
- Title
- append before jquery
- Category
- JavaScript
- Title
- event.stoppropagation
- Category
- JavaScript
- Title
- body-parser node
- Category
- JavaScript
- Title
- bind jquery trough name
- Category
- JavaScript
- Title
- clear terminal node js
- Category
- JavaScript
- Title
- forEach
- Category
- JavaScript
- Title
- javascript add scroll listener
- Category
- JavaScript
- Title
- if clicked outside of div jquery
- Category
- JavaScript
- Title
- get radio button value javascript
- Category
- JavaScript
- Title
- angular material table
- Category
- JavaScript
- Title
- angular one way property binding
- Category
- JavaScript
- Title
- Better Array check with Array.isArray Because arrays are not true array in JavaScript, there is no simple typeof check. No problem! Use the method Array.isArray to check…
- Category
- JavaScript
- Title
- form validation react
- Category
- JavaScript
- Title
- create a react native project
- Category
- JavaScript
- Title
- chart.js radar chart
- Category
- JavaScript
- Title
- discord.js dm user
- Category
- JavaScript
- Title
- edit onclick event
- Category
- JavaScript
- Title
- covid
- Category
- JavaScript
- Title
- Javascript compare two dates
- Category
- JavaScript
- Title
- free map js
- Category
- JavaScript
- Title
- how to remove an class in javascript
- Category
- JavaScript
- Title
- iterate through nested object javascript
- Category
- JavaScript
- Title
- how to set text for label in jquery
- Category
- JavaScript
- Title
- ascii to char in javascript
- Category
- JavaScript
- Title
- append to array js
- Category
- JavaScript
- Title
- how to do bubble sort in javascript
- Category
- JavaScript
- Title
- javascript bind event to created element
- Category
- JavaScript
- Title
- display none after hover
- Category
- JavaScript
- Title
- javascript check if two date are ugual
- Category
- JavaScript
- Title
- get url params angular
- Category
- JavaScript
- Title
- javascript add to a dictionary
- Category
- JavaScript
- Title
- firestore set a document
- Category
- JavaScript
- Title
- how to version a react app azure pipelines
- Category
- JavaScript
- Title
- how to delay redirect in javascript
- Category
- JavaScript
- Title
- how to multiple loop in javascript using for
- Category
- JavaScript
- Title
- brute force search javascript
- Category
- JavaScript
- Title
- append img to svg d3 js
- Category
- JavaScript
- Title
- custom status discord bot
- Category
- JavaScript
- Title
- Angular material design
- Category
- JavaScript
- Title
- fs create or edit file
- Category
- JavaScript
- Title
- bootstrap datepicker format dd-mm-yyyy
- Category
- JavaScript
- Title
- how to make javascript function consise
- Category
- JavaScript
- Title
- getting the value of pi in javascript
- Category
- JavaScript
- Title
- getcollectionnames
- Category
- JavaScript
- Title
- email regex
- Category
- JavaScript
- Title
- javascript add minutes to date
- Category
- JavaScript
- Title
- filter array objects javascript
- Category
- JavaScript
- Title
- how to remove attrivusre with jquery
- Category
- JavaScript
- Title
- client side redirect javascript
- Category
- JavaScript
- Title
- get today's date javascript
- Category
- JavaScript
- Title
- for javascript delay
- Category
- JavaScript