function deal(str) { return str.replace(/-(\w)/g, function($0, $1) { return $1.toUpperCase(); }); } const str = "add-add-add"; console.log(deal(str));