Encontre o elemento em uma matriz e substitua -o por uma função de retorno de chamada

var charSets = new Array("ab","bb","cd","ab","cc","ab","dd","ab");

function replaceElement(element,index,array) {
   if (element == "ab") array[index] = "**";

}

// apply function to each array element
charSets.forEach(replaceElement);
alert(charSets); // prints **,bb,cd,**,cc,**,dd,**
Confused Caiman