JSFiddle - React, Tailwind, and code Playground

by igor_9000

JavaScript

String.prototype.capitalize = function() {
    return this.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};


var myarr = [ "color - black", "color - blue", "color - Red" ]

for(var i=0; i < myarr.length; i++) {
		myarr[i] = myarr[i].capitalize().replace(/ -/g, ":");
}

console.log(myarr)