JavaScript remove sublinhado e capitalize

function humanize(str) {
  var i, frags = str.split('_');
  for (i=0; i<frags.length; i++) {
    frags[i] = frags[i].charAt(0).toUpperCase() + frags[i].slice(1);
  }
  return frags.join(' ');
}


humanize('humpdey_dumpdey');
// > Humpdey Dumpdey
Anxious Anaconda