convert strings into variables
<p>I have declared variables inside a map object, each one represents a location. Then i am using a listener to run a function on a click event so it shows some HTML and remove the previous shown. Works fine but i can see that starts to get repetitive very soon, not a DRY approach.</p>

<p>The HTML to be shown goes as follows:</p>

<pre><code>&lt;div class="grow-details"&gt;
    &lt;h2&gt;Informacion del Growshop&lt;/h2&gt;

    &lt;div id="imperioSeedsRecoleta" class="hide"&gt;
        &lt;h3&gt;Imperio Seeds&lt;/h3&gt;
        &lt;h5&gt;Calle Dardignac #527&lt;/h5&gt;

        &lt;p&gt;Sector Patronato&lt;/p&gt;
        &lt;p&gt;Recoleta&lt;/p&gt; 
        &lt;p&gt;Metro: Estacion Patronato&lt;/p&gt;
        &lt;p&gt;Contacto: 56 9 73507638 (Whatsapp)&lt;/p&gt;
        &lt;p&gt;Lunes a Viernes: 10:00 a 19:00 (Horario Continuado)&lt;/p&gt;
        &lt;p&gt;Sabados              : 10:00 a 16:00 hrs&lt;/p&gt;
        &lt;p&gt;Encargado tienda: Vicente Ogaz&lt;/p&gt;
    &lt;/div&gt;

    &lt;div id="somaGrowshop" class="hide"&gt;
        &lt;h3&gt;Soma Growshop&lt;/h3&gt;

        &lt;p&gt;José Miguel de La Barra 454, Santiago de Chile&lt;/p&gt;
        &lt;p&gt;Lun-Dom: 10:00-22:00&lt;/p&gt;
        &lt;p&gt;Cafetería Sensorial&lt;/p&gt;
        &lt;p&gt;No requiere reservas, Para llevar y Mesas en el exterior&lt;/p&gt;
        &lt;p&gt;Sirve Café y Bebidas&lt;/p&gt;
        &lt;p&gt;Teléfono (2) 2639 0442&lt;/p&gt;
    &lt;/div&gt;

    &lt;div id="growGames" class="hide"&gt;
        &lt;h3&gt;Grow Games | Grow Shop Chile&lt;/h3&gt;

        &lt;p&gt;GrowGames es un GrowShop, centrados en el trato directo con nuestros clientes, resolviendo cualquier duda que pueda surgirles, dando la solución mas económica y rápida posible.&lt;/p&gt;
        &lt;p&gt;Local 65,Merced 832,Santiago,Región Metropolitana&lt;/p&gt;
        &lt;p&gt;+56 9 8 158 00 45 | +56 2 2 696 82 97&lt;/p&gt;
        &lt;p&gt;info@growgames.cl&lt;/p&gt;
    &lt;/div&gt;

    &lt;div id="dinafem" class="hide"&gt;
        &lt;h3&gt;Dinafem Store Santiago&lt;/h3&gt; 
        &lt;p&gt;Av. Libertador Bernardo Ohiggins #482 8330030 Santiago Chile | Ecuador #78 Viña del Mar Chile&lt;/p&gt;
        &lt;p&gt;Llámanos ahora: Tienda Alameda: +569 64208716 Tienda en linea: +569 965061168&lt;/p&gt;
        &lt;p&gt;Escríbanos un Email a: compras@dinafemstore.cl&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt; 
</code></pre>

<p>Here is the JS files, variables represent a location in the map, and below are the listeners.</p>

<pre><code>var dinafem = new google.maps.Marker({
    position: {lat: -33.4420634, lng: -70.64286479999998},
    map: map,
    title: 'Dinafem'
});
var growGames = new google.maps.Marker({
    position: {lat: -33.4384068, lng: -70.64886280000002},
    map: map,
    // icon: 'assets/logo.png',
    title: 'Grow Games'
});
var imperioSeedsRecoleta = new google.maps.Marker({
    position: {lat: -33.4319006, lng: -70.64667589999999},
    map: map,
    // icon: 'assets/logo.png',
    title: 'Imperio Seeds'
});
var somaGrowShop = new google.maps.Marker({
    position: {lat: -33.4371948, lng: -70.6435702},
    map: map,
    title: 'Soma Grow Shop',
    draggable: true,
    animation: google.maps.Animation.DROP
});
</code></pre>

<p>My intention is to loop through each id name in the HTML to extract the id name convert it into a variable so i can call de adsListener method.</p>

<pre><code>imperioSeedsRecoleta.addListener("click", function() {
  document.getElementById("imperioSeedsRecoleta").removeAttribute("class", "hide");

    for (i = 0; i &lt; document.getElementsByClassName("grow-details")[0].children.length; i++) {        
        document.getElementsByClassName("grow-details")[0].children[i].setAttribute("class", "hide");       
        if (document.getElementsByClassName("grow-details")[0].children[i].id == "imperioSeedsRecoleta") {
            document.getElementById("imperioSeedsRecoleta").removeAttribute("class", "hide");
        }
    }
});

somaGrowShop.addListener("click", function() {
    document.getElementById("somaGrowshop").removeAttribute("class", "hide");

    for (i = 0; i &lt; document.getElementsByClassName("grow-details")[0].children.length; i++) {        
        document.getElementsByClassName("grow-details")[0].children[i].setAttribute("class", "hide");       
        if (document.getElementsByClassName("grow-details")[0].children[i].id == "somaGrowshop") {
            document.getElementById("somaGrowshop").removeAttribute("class", "hide");
        }
    }
});

growGames.addListener("click", function() {
    document.getElementById("growGames").removeAttribute("class", "hide");

    for (i = 0; i &lt; document.getElementsByClassName("grow-details")[0].children.length; i++) {        
        document.getElementsByClassName("grow-details")[0].children[i].setAttribute("class", "hide");       
        if (document.getElementsByClassName("grow-details")[0].children[i].id == "growGames") {
            document.getElementById("growGames").removeAttribute("class", "hide");
        }
    }
});

dinafem.addListener("click", function() {
    document.getElementById("dinafem").removeAttribute("class", "hide");

    for (i = 0; i &lt; document.getElementsByClassName("grow-details")[0].children.length; i++) {        
        document.getElementsByClassName("grow-details")[0].children[i].setAttribute("class", "hide");       
        if (document.getElementsByClassName("grow-details")[0].children[i].id == "dinafem") {
            document.getElementById("dinafem").removeAttribute("class", "hide");
        }
    }
});
</code></pre>

<p>If i create an empty array i can loop through each div id and push each id name that i conveniently named the same as its location variable</p>

<pre><code>var growsArray = [];

for (i = 0; i &lt; document.getElementsByClassName("grow-details")[0].children.length; i++) { 
    if (document.getElementsByClassName("grow-details")[0].children[i].id !== "") {       
        growsArray.push(document.getElementsByClassName("grow-details")[0].children[i].id);
    }
}
</code></pre>

<p>Each name is returned as a string so i cannot call .addlistener method to it. Is there any way to convert this strings to a variable?</p>