Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Conversion from CamelCase solution in Uncategorized category for Conversion from CamelCase by Elena_Korljukova
import assert from "assert";
function fromCamelCase(name: string): string {
for (let i of name.match(/[A-Z]/g)) name = name.replace(i,'_' + i.toLowerCase());
return name.slice(1);
}
console.log('Example:');
console.log(fromCamelCase('MyFunctionName'));
// These "asserts" are used for self-checking
assert.equal(fromCamelCase('MyFunctionName'), 'my_function_name');
assert.equal(fromCamelCase('IPhone'), 'i_phone');
console.log("Coding complete? Click 'Check' to earn cool rewards!");
July 3, 2020