Insert elements into the dom using 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 using foreach to loop through using createelement and appendchild?
April 19th 20 at 12:15
0 answer

Find more questions by tags JavaScript