How to convert a string with hyphens to PascalCase

Often time you’d encounter a case where you have to convert a string like
account-controller to to AccountController. The following subroutine should work for you

function PascalCase(string) {
  var str = string.replace(/-([a-z])/ig, function(all, letter) {
    return letter.toUpperCase();
  });
  return str.slice(0, 1).toUpperCase() + str.slice(1);
}

Sponsor : Text Messaging API | Javascript Engineer Jobs in LA