Hi, I do not understand why my code is not working. When I try to run it, I get this message:
TypeError: str.join is not a
function. (In str.join(‘ ‘),
‘str.join’ is not defined.)
Thanks in advance
Your code so far
function titleCase(str) {
str = str.toLowerCase().split(' ');
for (var i = 0; i < str.length; i++) {
str = str[i].charAt(0).toUpperCase() + str[i].slice(1);
}
return str.join(' ');
}
titleCase("I'm a little tea pot");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5
.
Link to the challenge: