JSFiddle - React, Tailwind, and code Playground
HTML
<div id="result">no result</div>
<div id="valid">no result</div>
JavaScript
$('#result').text("starting!");
var arr = new Array();
arr["US"] = true;
arr["CA"] = true;
arr["UK"] = false;
var ctry = "UK";
if (!arr[ctry]) {
$('#result').text("Not Valid!");
var txt = "";
for (var i in arr)
if (arr[i])
txt += i + " ";
$('#valid').text(txt);
} else {
$('#result').text("Valid!");
}