Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
How to push this array into an 2D array using GAS?

How can I have ar2 pushed into ar1 so as to have them like the Expected Output below?

ar1 = 
[
[true,160,"Blusa Crepe Barcelona manga curta",2,"","","",100],
[true,161,"Blusa Crepe Barcelona manga curta",1,"","","",100]
]
ar2 = ["Concluído",1000]

Expected Output

result = [
[true,160,"Blusa Crepe Barcelona manga curta",2,"","","",100,"Concluído",1000],
[true,161,"Blusa Crepe Barcelona manga curta",1,"","","",100,"Concluído",1000]
]

I've tried doing it using a douple for loop, but I haven't been able to make it right, as it pushes ar2 as another array in the outer array:

let output= [];
for (let i = 0; i < ar1.length; i++){
    for (let j = 0; j < ar1[i].length; j++){
        output.push(ar1[j],ar2)
    }
}

Appreaciate your help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To concat the array you can use concat() method

ar1 = 
[
[true,160,"Blusa Crepe Barcelona manga curta",2,"","","",100],
[true,161,"Blusa Crepe Barcelona manga curta",1,"","","",100]
]
ar2 = ["Concluído",1000]

for(let i = 0; i<ar1.length;i++){
 ar1[i] = ar1[i].concat(ar2)
}

console.log(ar1)

For more info on concat() please refer here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!