html5 - How to replace character from array items using javascript? -
i have got array items dynamically ["{text: "us"}", "{text: "mexico"}", "{text: "brazil"}"]. need replace char "{ char { , char }" char }. after replacing need output [{text: "us"}, {text: "mexico"}, {text: "brazil"}]. if single object means can replace. array list not getting. have tried below, 1 not working how can achieve one? great appreciated. thank you.
dynamicsubregions =["{text: "us"}", "{text: "mexico"}", "{text: "brazil"}"]; var dynamicsubregionsfinal = dynamicsubregions[dynamicsubregions.indexof('"{')] = '{';
your array syntax wrong , double quotes arn't inside variable
dynamicsubregions =["{text: \"us\"}", "{text: \"mexico\"}", "{text: \"brazil\"}"]; alert(dynamicsubregions[0]);
Comments
Post a Comment