0
5. Write a JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in
5. Write a JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case. Example string : 'the quick brown fox' Expected Output : 'The Quick Brown Fox '
1 Antwort
+ 3
Well, You can use
var data = 'the quick brown fox';
function capital(str){
return str.replace(/\b\w/g,function(x){
return x.toUpperCase(x);
});
}
alert(capital(data));
I have use regex for that