Friday, 6 September 2013

whats wrong with my capitalize letters in words code?

whats wrong with my capitalize letters in words code?

function LetterCapitalize(str) {
return str.charAt(0).toUpperCase()+ str.slice(1);
var spaceIndex=str.indexOf(' ');
var first=str.substring(0,spaceIndex);
var second=str.substring(spaceIndex+1,str.length)
return LetterCapitalize(first)+" " + LetterCapitalize(second)
}
console.log(LetterCapitalize("hello world"))
not sure what i did wrong but only H in hello is capitalized

No comments:

Post a Comment