Answers for "uncapitalize string js"

2

capitalize string js

With performance metrics...

// 10,889,187 operations/sec
function capitalizeFirstLetter(string) {
    return string[0].toUpperCase() + string.slice(1);
}

// 10,875,535 operations/sec
function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

// 4,632,536 operations/sec
function capitalizeFirstLetter(string) {
    return string.replace(/^./, string[0].toUpperCase());
}

// 1,977,828 operations/sec
String.prototype.capitalizeFirstLetter = function() {
    return this.charAt(0).toUpperCase() + this.slice(1);
}
Posted by: Guest on May-28-2021
0

capitalize a string javascript

const Capitalize = function(string){
  return string[0].toUpperCase + string.slice(1).toLowerCase;
}
Posted by: Guest on March-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language