what’s wrong with my code , it is telling me Cannot read property ‘toUpperCase’ of undefined. 4 times.
Your code so far
function titleCase(str) {
let new223 = str.toLowerCase();
let new22 = new223.split('');//splits string into array
new22[0].toUpperCase(); //capitazlizes first letter in the array
// this loop watches for a space and then captializes the letter just after it (x+1)
for(let x in new22){
if(new22[x] ===" "){
new22[x+1].toUpperCase();
}
}
new22.join(); //joins the array
return new22;
}
titleCase("I'm a little tea pot");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence