Tell us what’s happening:
I’m supposed to turn the first letter of every word in a string capital and all the others lowercase.
Not sure why the tests are failing, console logging the newStr gives me the correct output .
Your code so far
function titleCase(str) {
var arr = str.split(" ")
var newStr = "";
for (let i = 0; i < arr.length; i++) {
let noLetter = arr[i].slice(1).toLowerCase() + " ";
let upperCase = arr[i].charAt(0).toUpperCase();
newStr += upperCase + noLetter;
}
return newStr;
}
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.