I
I
Ibishka2020-04-16 08:27:12
JavaScript
Ibishka, 2020-04-16 08:27:12

Insert elements into dom via map or foreach?

document.querySelector("#mapBtns").innerHTML = coords
    .map(
      (e, i) =>
        `<button class="map-btn ${
          i == 0 ? "active" : ""
        }" data-coord="${JSON.stringify(e.coord)}">${e.title}</button>`
    )
    .join("");

Or through foreach to sort through and using createelement appendchild?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question