Code:
function titleCase(str) {
let a = str.concat();
a = a.toLowerCase().split(" ");
let v = a.map(function(item){
item[0] = item[0].toUpperCase();
return item;
});
return v.join(" ");
}
console.log(titleCase("I'm a little tea pot"));//output should be "I'm A Little Tea Pot" but shows "i'm a little tea pot"
The code should simply show the output as indicated in the comment on the last line. The value of item[0]
is not changing.