Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const convertCamel = function (varNames) {
- const initial = varNames.trim().toLowerCase();
- const converted = initial.slice(initial.indexOf('_')).replace('_', '');
- const capitalize = converted.replace(
- converted[0],
- converted[0].toUpperCase()
- );
- const camaled = initial.slice(0, initial.indexOf('_')) + capitalize;
- const ticks = '✅'.repeat(converted.length); // Add green ticks based on the length of the converted variable name
- return `${camaled}${ticks}`;
- };
- console.log(convertCamel('underscore_case'));
- console.log(convertCamel('first_name'));
- console.log(convertCamel('Some_Variable'));
- console.log(convertCamel(' calculate_AGE'));
- console.log(convertCamel('delayed_departure'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement