Title Case a Sentence Not Working

Tell us what’s happening:

How am I able to concatenate the words together?
It’s being individually lined.

Your code so far


function titleCase(str) {
    let myStr = str.toLowerCase().split(' ');
    let newStr = '';

    for(var x = 0; x < myStr.length; x++){
        newStr = myStr[x].charAt(0).toUpperCase() + myStr[x].slice(1);
        console.log(newStr);
    }
    return newStr;
}

titleCase("I'm a little tea pot");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence

You should look into the join method.

Also realize that your variable myStr is not a string, it’s an array of strings. I would advise making changes to each of those strings in the array - in the for loop. Then, after the for loop, you can join and return it.