After parsing values through Ajax request (GET), I need to replace them with other values -> i.e. multiple postal codes corresponding to the same country code ( "1991,1282,6456" : "Idaho", etc. )
This is what I've done so far :
$mapCodes = {
'1991': 'Idaho',
'1282': 'Idaho',
'5555': 'Kentucky',
'7777': 'Kentucky '
}
var region = value.groupid.replace(/7777|5555|1282|1991/, function(matched) {
return $mapCodes[matched];
});
console.log(region);
This works, but I'd rather avoid setting my $mapCodes variable as a long list of values repeated.
I need something like and array of array to whitch make the match (and then the replacement)
$mapCodes = {
'1991,1282' : 'Idaho',
'7777,5555' : 'Kentycky'
}
value.groupiddefined. I also added a quote and a comma to the invalid object"Kentucky": [7777,5555]and look them up using value search