Answers for "js string seprate camelcase"

2

camelcase to hyphenated javascript

let dashed = camel.replace(/[A-Z]/g, m => "-" + m.toLowerCase());
Posted by: Guest on July-07-2020
0

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 "Javascript"

Browse Popular Code Answers by Language