I want to capitalize the first letter of every word in a string.
I want to know why this is not working:
function titleCase(str) {
  str = str.toLowerCase().split(" ");
  for(let i = 0; i<ar.lrngth;i++){
    ar[i][0] = ar[i][0].toUpperCase();
  }
  return ar;
}
console.log(titleCase("I'm a little tea pot"));
Nor this:
function titleCase(str) {
  str = str.toLowerCase().split(" ");
  let _ar = [];
  _ar =str.map(item => item.map( cap => cap.toUpperCase()));
  return _ar;
}
console.log(titleCase("I'm a little tea pot"));
I would like to know if there are any one liners that can do this too : same operation on elements of subarrays
 
     
     
     
     
    