Los Angeles, CA

How to convert a string with hyphens to camelCase

How to convert a string with hyphens to camelCase

function camelCase(string) {
  return string.replace(/-([a-z])/ig, function(all, letter) {
    return letter.toUpperCase();
  });
}

 

 

Facebook Comments