JSFiddle - React, Tailwind, and code Playground
JavaScript
var distinctCtyNames = ['Toronto', 'Moscow', 'New York'];
for (ctyKey in distinctCtyNames) // changed to ctyKey
{
var ctyName = distinctCtyNames[ctyKey]; // get ctyName
var element = document.createElement('div');
element.id = ctyName;
element.innerText = ctyName;
document.body.appendChild(element);
}