capitalize first letter javascript
JavaScript
//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(); });
};const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
console.log(capitalizeFirstLetter('foo bar bag')); // Foofunction capitalize2(str) {
str = str.toLowerCase();
const arrOfWords = str.split(" ");
const arrOfWordsCased = [];
for (let i = 0; i < arrOfWords.length; i++) {
const char = arrOfWords[i].split("");
char[0] = char[0].toUpperCase();
res.push(char.join(""));
}
return arrOfWordsCased.join(" ");
}
Also in JavaScript:
- Title
- how to clear terminal in vs code
- Category
- JavaScript
- Title
- import vue js
- Category
- JavaScript
- Title
- clone a JavaScript object
- Category
- JavaScript
- Title
- D3.js
- Category
- JavaScript
- Title
- how to generate random character from an array js
- Category
- JavaScript
- Title
- compare string by several strings js
- Category
- JavaScript
- Title
- how to make a textarea unwritable in react native
- Category
- JavaScript
- Title
- javascript check if string is number
- Category
- JavaScript
- Title
- hide element by name javascript
- Category
- JavaScript
- Title
- foreach and replace item based on condition
- Category
- JavaScript
- Title
- convert 2 lists to json python
- Category
- JavaScript
- Title
- how to version a react app azure pipelines
- Category
- JavaScript
- Title
- javascript check if string contains substring
- Category
- JavaScript
- Title
- format date javascript
- Category
- JavaScript
- Title
- how to get the size of the window in javascript
- Category
- JavaScript
- Title
- dotenv not loading process.env in node
- Category
- JavaScript
- Title
- array.splice javascript
- Category
- JavaScript
- Title
- disable mouse right click javascript
- Category
- JavaScript
- Title
- express route parameters
- Category
- JavaScript
- Title
- express validator always return error
- Category
- JavaScript
- Title
- chart js rotating the x axis labels
- Category
- JavaScript
- Title
- array find method javascript
- Category
- JavaScript
- Title
- fetch response json or text
- Category
- JavaScript
- Title
- add firebase in react
- Category
- JavaScript
- Title
- how to append object in array javascript
- Category
- JavaScript
- Title
- how get a json object from an api in javascript
- Category
- JavaScript
- Title
- get a div text content and store in a variable js
- Category
- JavaScript
- Title
- interceptor in angular 8
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- get current directory vbscript
- Category
- JavaScript
- Title
- format a date moment
- Category
- JavaScript
- Title
- how to get element from arraylist react
- Category
- JavaScript
- Title
- angular material theme colors
- Category
- JavaScript
- Title
- creating a 2d array in js
- Category
- JavaScript
- Title
- how to attach javascript to html
- Category
- JavaScript
- Title
- datatables server side
- Category
- JavaScript
- Title
- javascript call php function with parameters
- Category
- JavaScript
- Title
- how to access data in firebase realtime
- Category
- JavaScript
- Title
- angular component lifecycle hooks
- Category
- JavaScript
- Title
- faunadb ref
- Category
- JavaScript
- Title
- document addeventlistener click
- Category
- JavaScript
- Title
- javacript count properties
- Category
- JavaScript
- Title
- html parser javascript
- Category
- JavaScript
- Title
- google sign in in firebase react
- Category
- JavaScript
- Title
- go to page jquery
- Category
- JavaScript
- Title
- angular list contains property
- Category
- JavaScript
- Title
- how to add class to element on mouseclick with js
- Category
- JavaScript
- Title
- create array of objects javascript
- Category
- JavaScript
- Title
- how to make dynamic columns in jquery
- Category
- JavaScript
- Title
- expo open app settings
- Category
- JavaScript
- Title
- if clicked outside of div jquery
- Category
- JavaScript
- Title
- how to deap clone an object in javascript
- Category
- JavaScript
- Title
- how to write in js
- Category
- JavaScript
- Title
- add discord.js library
- Category
- JavaScript
- Title
- addEventListener
- Category
- JavaScript
- Title
- ellipsis javascript
- Category
- JavaScript
- Title
- arrays javascript
- Category
- JavaScript
- Title
- fizz buzz javascript
- Category
- JavaScript
- Title
- firebase configuration on functions
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- inser js
- Category
- JavaScript
- Title
- export aab bundle react native android
- Category
- JavaScript
- Title
- iterate over object javascript
- Category
- JavaScript
- Title
- How to check whether a checkbox is checked in jQuery?
- Category
- JavaScript
- Title
- client side redirect javascript
- Category
- JavaScript
- Title
- how to initialize an array in javascript
- Category
- JavaScript
- Title
- javascript check string lenght
- Category
- JavaScript
- Title
- how to run different node app on server different domains
- Category
- JavaScript
- Title
- history.pushstate
- Category
- JavaScript
- Title
- how to get user ip address in javascript
- Category
- JavaScript
- Title
- how to add onclick event in javascript
- Category
- JavaScript
- Title
- how to remove a property from an object in javascript
- Category
- JavaScript
- Title
- empty a select input using js
- Category
- JavaScript
- Title
- javascript clear file input
- Category
- JavaScript
- Title
- element clicked js
- Category
- JavaScript
- Title
- how to host react app on heroku
- Category
- JavaScript
- Title
- area of a circle
- Category
- JavaScript
- Title
- Encoding and Decoding Base64 Strings in Node.js
- Category
- JavaScript
- Title
- javascript add day to date
- Category
- JavaScript
- Title
- javascript array flat
- Category
- JavaScript
- Title
- bootstrap 4 hide modal via javascript
- Category
- JavaScript
- Title
- array javascript
- Category
- JavaScript
- Title
- javascript after split then trim whitespace
- Category
- JavaScript
- Title
- how to add objects in array
- Category
- JavaScript
- Title
- how to handle two url in one route in react
- Category
- JavaScript
- Title
- function and returns node js
- Category
- JavaScript
- Title
- angularjs iframe src binding
- Category
- JavaScript
- Title
- how to check if local storage variable exists in javascript
- Category
- JavaScript
- Title
- email regex javscript
- Category
- JavaScript
- Title
- allow cross origin node
- Category
- JavaScript
- Title
- javascript add multiple items to array
- Category
- JavaScript
- Title
- ipv4 to int32 js
- Category
- JavaScript
- Title
- array of objects javascript
- Category
- JavaScript
- Title
- how to push object in array using for loop javascript
- Category
- JavaScript
- Title
- get data from json using jquery
- Category
- JavaScript
- Title
- angular right click on link
- Category
- JavaScript
- Title
- javascript check if array is in array
- Category
- JavaScript
- Title
- () = javascript
- Category
- JavaScript
- Title
- double question mark javascript
- Category
- JavaScript
- Title
- how to calculate balance automatically using javascript and php using cash paid
- Category
- JavaScript