Answered by : code-grepper
//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(); });
};
Source : | Last Update : Mon, 29 Jul 19
Answered by : xerothermic-xenomorph-wa03p7gj567j
function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1);
}
console.log(capitalizeFirstLetter('foo')); // Foo
Source : https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript | Last Update : Mon, 07 Sep 20
Answered by : you
function capitalizeFirstLetter(str) { return str.charAt(0).toUpperCase() + str.slice(1);
}
// Example usage
const myString = "hello world";
const capitalizedString = capitalizeFirstLetter(myString);
console.log(capitalizedString); // Output: "Hello world"
Source : | Last Update : Tue, 19 Sep 23
Answered by : you
function capitalizeFirstLetter(str) { return str.charAt(0).toUpperCase() + str.slice(1);
}
// Example usage
const text = "hello world";
const capitalizedText = capitalizeFirstLetter(text);
console.log(capitalizedText); // Output: "Hello world"
Source : | Last Update : Tue, 19 Sep 23
Answered by : kazi-mahbubur-rahman
const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
Source : | Last Update : Wed, 27 Jul 22
Answered by : praise-owode
var name = prompt("What is your name");
firstLetterUpper = name.slice(0,1).toUpperCase();
alert("Hello " + firstLetterUpper + name.slice(1, name.length).toLowerCase());
Source : | Last Update : Mon, 17 Oct 22
Answered by : grieving-gharial-54afdxs4rdwl
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1);
}
Source : https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-javascript | Last Update : Mon, 02 Aug 21
Answered by : rodrigo-a-f-garcia
const names = ["alice", "bob", "charlie", "danielle"];
const namesCap = names.map((name) => { return `${name[0].toUpperCase()}${name.slice(1)}`;
});
console.log(namesCap);
Source : https://www.ingroy.com | Last Update : Wed, 13 Apr 22
Answered by : saptarshi-mondal
function ucwords (str) { return (str + '').replace(/^([a-z])|\s+([a-z])/g, function ($1) { return $1.toUpperCase(); });
}
console.log(ucwords("hello world"));
Source : | Last Update : Sat, 24 Apr 21
Answered by : sergey-dragoner
const upperCase = function(names){ const toLower = names.toLowerCase().split(' '); const namesUpper = []; for(const wordName of toLower){ namesUpper.push(wordName[0].toUpperCase() + wordName.slice(1)); } return namesUpper.join(' ');
}
Source : | Last Update : Thu, 07 Jan 21