Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Capitalize The String

const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1)

capitalize("follow for more")
// Result: Follow for more
Comment

Capitalize a String

const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1)

capitalize("javascript one-liners are fun")
//Javascript one-liners are fun
Comment

capitalize words in a string

/**
 * Capitalizes first letters of words in string.
 * @param {string} str String to be modified
 * @param {boolean=false} lower Whether all other letters should be lowercased
 * @return {string}
 * @usage
 *   capitalize('fix this string');     // -> 'Fix This String'
 *   capitalize('javaSCrIPT');          // -> 'JavaSCrIPT'
 *   capitalize('javaSCrIPT', true);    // -> 'Javascript'
 */
const capitalize = (str, lower = false) =>
  (lower ? str.toLowerCase() : str).replace(/(?:^|s|["'([{])+S/g, match => match.toUpperCase());
;
Comment

PREVIOUS NEXT
Code Example
Javascript :: download canvas js 
Javascript :: javascript how to check if object property exists 
Javascript :: javascript get element position relative to document 
Javascript :: set headers in express 
Javascript :: remove specific property from json object javascript 
Javascript :: jquery select clear options 
Javascript :: remove single item from array in angular 
Javascript :: pauze js 
Javascript :: bootstrap js, jQuery, popper cdn 
Javascript :: async await anonymous function 
Javascript :: hardhat test 
Javascript :: zoom out browser javascript 
Javascript :: extract words from string js 
Javascript :: javascript find string between two characters 
Javascript :: form validation using jquery 
Javascript :: jquery remove focus 
Javascript :: TypeError: (0 , T.useState) is not a function 
Javascript :: queryselector data attribute 
Javascript :: js how to get data fetch 
Javascript :: nestjs change httpcode inside function 
Javascript :: javascript truncate array 
Javascript :: if else short term 
Javascript :: js spread exclude property 
Javascript :: strapi production build 
Javascript :: usestate with string 
Javascript :: js get all indexes of value in array 
Javascript :: cypress click 
Javascript :: how to compare strings in javascript ignoring case sensitive 
Javascript :: validate latitude longitude javascript 
Javascript :: joi string custom validation fuction 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =