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 '

9th Dec 2016, 12:41 PM
Nashwan Aziz
Nashwan Aziz - avatar
1 Resposta
+ 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
9th Dec 2016, 2:16 PM
Aditya kumar pandey
Aditya kumar pandey - avatar