Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear&Readable solution in Clear category for [old] Conversion from CamelCase by SaintDron
"use strict";
function fromCamelCase(name) {
const f = (m) => '_' + m.toLowerCase();
return name.replace(/[A-Z]/g, f).slice(1);
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(fromCamelCase('Name'))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(fromCamelCase("MyFunctionName"), "my_function_name")
assert.equal(fromCamelCase("IPhone"), "i_phone")
assert.equal(fromCamelCase("ThisFunctionIsEmpty"), "this_function_is_empty")
assert.equal(fromCamelCase("Name"), "name")
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
March 26, 2018