Answers for "string convert in camel case in javascript"

2

Convert string to camel case

def to_camel_case(text):
    if text == '':
        return text
    for i in text:
        if i == '-' or i == '_':
            text = text.replace(text[text.index(i):text.index(i)+2], text[text.index(i)+1].upper(), 1)
    return text
Posted by: Guest on April-04-2021
1

javascript to camelcase

String.prototype.toCamelCase = function () {
	let STR = this.toLowerCase()
		.trim()
		.split(/[ -_]/g)
		.map(word => word.replace(word[0], word[0].toString().toUpperCase()))
		.join('');
	return STR.replace(STR[0], STR[0].toLowerCase());
};
Posted by: Guest on August-01-2021

Code answers related to "string convert in camel case in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language