Im having trouble with this algorithm challenge.
my code works for all cases except for this instance I get “I’M A Little Tea Pot” I cant figure out how to keep the M and the A from capitalizing. I cant figure the proper REGEX to prevent this. Any help would be appreciated!
Thanks
function titleCase(str) {
var string = str.toLowerCase();
function upper(match){
return match.toUpperCase();
}
return string.replace(/\b(\w)/g, upper);
}
titleCase("I'm a little tea pot");