JSFiddle - React, Tailwind, and code Playground

JavaScript

var postCodes = [{countryCode:"US", regionCode:"NAmerica"},{countryCode:"CHN" ,regionCode:"ASIA"}, {countryCode:"CAN", regionCode:"NAmerica"}];

for(var i=0; i<postCodes.length; i++){
$('<button />', {'text':postCodes[i].countryCode})
                .click(getHandler(postCodes[i]))
                .appendTo('body');
}


function getHandler(postCode){
      return function () {
            console.log(postCode);
       }
    }