var obj = [
{“name”: “Afghanistan”, “pre”: “AF”},
{“name”: “Åland Islands”, “pre”: “AX”},
{“name”: “Albania”, “pre”: “AL”},
{“name”: “Algeria”, “pre”: “DZ”}
];
// the pre you're looking forvar needle = 'AL';// iterate over each element in the arrayfor (var i = 0; i < obj.length; i++){ // look for the entry with a matching `pre` value if (obj[i].pre == needle){ // we found it // obj[i].name is the matched result }}


