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

303
Vistas
The Array is empty - foreach() does not seam to work || The values does not get passed into the loop

const filteredOptions = _.filter(grantedValuesFinal, o => o.numberOfShareOptionAwardGranted > 0);

let filteredArray = []; 
filteredOptions.forEach(function(item, i){
  
  let existing = filteredArray.filter(function(o, i) {
    const dateNew = luxon.DateTime.fromISO(o.grantDate);
    const dateExsisting = luxon.DateTime.fromISO(item.grantDate);

    return o.grantDate == item.grantDate; 
  });

  if (existing.length) {
    let existingIndex = filteredArray.indexOf(existing[0]);
    if(item.typeOfEquity == "Shares") filteredArray[existingIndex].numberOfShareOptionAwardGrantedShares += item.numberOfShareOptionAwardGranted;  
    if(item.typeOfEquity == "Options") filteredArray[existingIndex].numberOfShareOptionAwardGrantedOptions += item.numberOfShareOptionAwardGranted;  
    
  } else {
      let numberOfShareOptionAwardGrantedShares = 0, numberOfShareOptionAwardGrantedOptions = 0;
      if(item.typeOfEquity == "Shares") numberOfShareOptionAwardGrantedShares += item.numberOfShareOptionAwardGranted; 
      if(item.typeOfEquity == "Options") numberOfShareOptionAwardGrantedOptions += item.numberOfShareOptionAwardGranted; 
      filteredArray.push({grantDate: item.grantDate, numberOfShareOptionAwardGrantedShares: numberOfShareOptionAwardGrantedShares, numberOfShareOptionAwardGrantedOptions: numberOfShareOptionAwardGrantedOptions }); 
  }
}) 

The very first line of the code does not pass any value, due to which filteredOptions and array is empty. What changes has to be done ? Please help

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The filteredOptions array always stayed NULL as the grantedValuesFinal was only filtering out NULL values.

I was able to work out the code by placing !=NULL and got the non-null values. Thank you all for your insights

about 4 years ago · Juan Pablo Isaza Denunciar
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