const cities = data.cities const last_city = cities.name.length - 1 const ui = { map_pieces: document.getElementById("pieces"), cities: [], } function on_init() { for (let s = 0; s <= last_city; ++s) { let e = ui.cities[s] = document.createElement("div") e.className = "city" e.style.left = (cities.x[s] - 9) + "px" e.style.top = (cities.y[s] - 9) + "px" map_pieces.appendChild(e) } } on_init()