const camelizeRE = /-(\w)/g const camelize = (str) => { return str.replace(camelizeRE, (_, c) => { return c ? c.toUpperCase() : ''; }) } console.log(camelize('hello-world'));