Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
Filtered array returns as 'undefined' in a Leaflet popup
array = [{"shop":"Big Store", "name":"Green Bag"},
         {"shop":"Long Store", "name":"Red Shoes"},
         {"shop":"Big Store", "name":"White Tree"}]

To filter it, I made this function

function filterByShop(array, key, String) {
  return array.filter((obj) => obj[key] == String)
};

If I do alert(JSON.stringify(filterByShop(array, "shop", "Big Store"))), it returns the array minus the Long Store item.

However, if I attach the filtered array to a Leaflet popup via this function, it returns as undefined

function shopsPopup(feature, json){
  json.bindPopup(feature.properties.shop + "</br>" +
                 feature.properties.name + "</br>" +
                 JSON.stringify(filterByShop(array, "shop", feature.properties.shop)))
}

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda