Its argument is xx-xxx-xx converted to xxXxxXxx
// 1. camelCasing conversion and encapsulation function changeString (A) { // var A = 'GET-Element-ID'; var B = a.split ( '-'); // Split the specified string was cut into an array of characters for ( var I = 0; I <to b.length; I ++) { // loop through the array b // the charAt method to find the index 0 is the first character, the toUpperCase lowercase to uppercase, and then behind the splicing character B [I] = B [I] .charAt (0) .toUpperCase () + B [I] .substr (. 1, B [I]-.length. 1 ) } return b.join ( '' ); // the Join function splicing (splicing default comma toString == ()) } the console.log (changeString ( 'GET-Element-ID'));