Tell us what’s happening:
Describe your issue in detail here.
Doing the short capitalization challenge, pretty sure I have the right results but it says I dont.
**Your code so far**
function titleCase(str) {
let str2 = []
str2 = str.split(' ');
str = ''
for(let i = 0; i < str2.length; i++){
str += (str2[i].substr(0,1).toUpperCase()).concat(str2[i].substr(1).toLowerCase() + ' ');
//console.log(str)
}
str.trim();
//console.log(str)
return str;
}
//titleCase("I'm a little tea pot");
console.log(titleCase("sHoRt AnD sToUt"));
console.log(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT"))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0
I’ve been recently advised to make more use of new variables when making assignment (=) so to use ‘const’ more than ‘let’.
(i’m just a noob, so pinch of salt with my advice, but i think you could apply that here). some functions mutate a value (could be best avoided anyway) and some return a new thingumeejig. )