<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script type="text/javascript"> window.onload = function() { new Camel('border-bottom-color'); } function Camel(str) { this.result = ''; this.arr = str.split('-'); this.result += this.arr[0].toString(); for(var i = 1; i < this.arr.length; i++) { var str1 = this.arr[i].toString(); var str2 = str1.charAt(0).toUpperCase(); var str3 = str2 + str1.slice(1); this.result += str3; } console.log(this.result); } </script> </body> </html>