Tell us what’s happening:
Ignore the fact that i’m console.log ging instead of returning, i did that just for debugging. my For loop, in particular, doesn’t seem to have any effect. i know the mistake is in there somewhere, but i keep looking at it but can’t figure it out.
Your code so far
function titleCase(str) {
let wordArr = str.split(" ");
for (let i = 0; i < wordArr.length; i++){
wordArr[i].toLowerCase();
wordArr[i][0].toUpperCase();
}
console.log(wordArr.join(" "));
}
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/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence