In the line you need to find all the hyphens or underscores, remove them and make the letter after them big:

function toCamelCase(string) { return string.replace(/-|_/gi, (str, index, s) => { return s[index + 1].toUpperCase(); }); } console.log(toCamelCase("the-stealth-warrior")); 

    1 answer 1

    It is also necessary to capture the first letter, otherwise replace does not replace it:

     function toCamelCase(string) { return string.replace(/(?:-|_)\w/gi, (str, index, s) => { return s[index + 1].toUpperCase(); }); } console.log(toCamelCase("the-stealth-warrior"));