1//capitalize only the first letter of the string.
2function capitalizeFirstLetter(string) {
3 return string.charAt(0).toUpperCase() + string.slice(1);
4}
5//capitalize all words of a string.
6function capitalizeWords(string) {
7 return string.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
8};
1const names = ['Ali', 'Atta', 'Alex', 'John'];
2
3const uppercased = names.map(name => name.toUpperCase());
4
5console.log(uppercased);
6
7// ['ALI', 'ATTA', 'ALEX', 'JOHN']
8