Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Conversion into CamelCase by pdolgov
import assert from "assert";
function toCamelCase(name: string): string {
return name.replaceAll(/(^|_)([a-z])/g, (_1,_2,s)=>s.toUpperCase());
}
console.log('Example:');
console.log(toCamelCase('my_function_name'));
// These "asserts" are used for self-checking
assert.equal(toCamelCase('my_function_name'), 'MyFunctionName');
assert.equal(toCamelCase('i_phone'), 'IPhone');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
Feb. 25, 2022