Tell us what’s happening:
Hey everybody,
I am on Basic Algorithm Scripting: Title Case a Sentence.
I don’t understand why the I of little is not a lowercase.
Someone can help me with that please ?
Thanks
Your code so far
function titleCase(str) {
let strSplitted = str.split('');
let result = "";
const strSplittedLowerCase = strSplitted.map( letters => { return letters.toLowerCase()});
for(let i=0 ; i<strSplittedLowerCase.length ; i++){
//console.log(strSplitted[i].toUpperCase())
if(strSplittedLowerCase[i-1] === ' ' || strSplittedLowerCase[i] === strSplittedLowerCase[0]){
result += strSplittedLowerCase[i].toUpperCase()
}else{
result += strSplittedLowerCase[i]
}
}
return result;
}
console.log(titleCase("I'm a little tea pot"));
console.log(titleCase("sHoRt AnD sToUt"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.
Challenge: Title Case a Sentence
Link to the challenge: