How to get variable declared globaly using name assigned to string variable? In this example copyButtons have data-field="html", second data-filed="css" and so on.
const htmlArea = document.querySelector(".htmlCopy");
const cssArea = document.querySelector(".cssCopy");
const jsArea = document.querySelector(".jsCopy");
const copyButtons = document.querySelectorAll(".copyBtn");
copyButtons.forEach(function(el) {
el.addEventListener("click", copyTextfield);
});
function copyTextfield() {
const place = this.dataset.field+"Area";
//use a variable named like place
}