Tell us what’s happening:
When I am using this piece of code is jsfiddle.net it shows me perfect result. Even in FCC console log its showing correct result for all the testcases but somehow it is not passed, not sure why.
Your code so far
function titleCase(str) {
var words = str.split(' ');
var ans = "";
for(var i = 0; i < words.length; i++) {
ans += words[i].charAt(0).toUpperCase() +
words[i].substring(1).toLowerCase() +
" ";
}
return ans;
}
titleCase("sHoRt AnD sToUt");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36
.
Link to the challenge: