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

173
Vistas
How to concatenate 2 multidimensional arrays matching criteria in JS?

How can I add 02 elements/columns to array1, if a couple of criteria are met in the following scenario?

noPedido = 1000
let ordersData = sheet1.getRange(2, 1, sheet1.getLastRow(), sheet1.getLastColumn()).getValues();
let deliveryData = sheet2.getRange(2, 1, sheet2.getLastRow(), 13).getValues();
for (let a = deliveryData .length - 1; a >= 0; a--) {
      for (let n = ordersData .length - 1; n >= 0; n--) {
        if (deliveryData[a][12] == noPedido && ordersData[n][11] == noPedido
          && deliveryData[a][1] == ordersData[n][1]) {
          let row = n + 2;
          let qtds = [deliveryData [a][4], deliveryData [a][5]];
          sheet1.getRange(row, 24, 1, 2).setValues([qtds]);//Adds found data to adjacent columns
        }
      }
    }

If I had a 2D array ordersData, which I do, I wouldn't have to get the values so I could get its rows in sheet1, where I'm setting the values.

Thanks.

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

0

From sheet1.getRange(row, 24, 1, 2).setValues([qtds]);//Adds found data to adjacent columns in your script, if you want to add qtds to the same row of ordersData[n], how about the following modification?

From:

sheet1.getRange(row, 24, 1, 2).setValues([qtds]);

To:

ordersData[n] = [...ordersData[n], ...qtds];
  • In this modification, the values of qtds is added to the same row of ordersData[n].
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