I have an array
var myarr = [ "color - black", "color - blue", "color - Red" ]
And I want want to replace " - " with ":" and capitalize the first letter of every word in that array:
var myarr = [ "Color: Black", "Color: Blue", "Color: Red" ]
I try
for (var i = 0; i < myarr.length; i++) {
myarr[i] = myarr[i][0].toUpperCase()+myarr[i].replace(/ -/g, ":").substring(1);
}
But it works only for the first word