Tell us what’s happening:
I have run this code and i am getting the same result as shown in the test but still it is not passing the test . Is something wrong with my code or is it the test failing??
i know i shou
Your code so far
function titleCase(str) {
return str.toLowerCase().split(' ')
.reduce(function (acc,cur){
let cap= cur.charAt(0).toUpperCase();
// console.log(cap)
let newCap= cur.replace(cur.charAt(0),cap);
// console.log(newCap);
return acc + " " + newCap;
},'')
//
}
titleCase("I'm a little tea pot");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.
Challenge: Title Case a Sentence
Link to the challenge: