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

226
Views
Move an array in the place of another array

I am in the making of an apps script, that takes a specified range, divides it into subranges of 4 values each, and returns the array. It looks like this:

Range

Code that follows that to divide it into said subranges:

function sort() {
    
    const chunks = (range, size) =>
    Array.from(
        new Array(Math.ceil(range.length / size)),
        (_, i) => range.slice(i * size, i * size + size)
    );
    let range = ranges.getValues().flat();
    var array = chunks(range, 4)
      }
    }
  } 
}

Now, what I want to do with these, is that when someone removes data from one of the subranges, the ones below will go up, so that there are no gaps between the subranges. What I mean by that, is in the case of someone clearing data from, for example, the second subrange, all the ones that are below will go up.

NOTE: It is just a function that I later use in onChange(), and the ranges variable was called earlier throughout the code, and it's just a named range.

So far I've got this piece of code, but it doesn't seem to work:

for (let i = 0; i < array.length; i++) {
      for (let j = 0; j < 4; j++) {
        var equ = 0;
        var mult = 0;
        equ += array[i][j];
        mult += array[i+1][j];
        if (equ == 0 || "" && mult != "" && 0) {
          array[i+1].copyTo(array[i], {contentsOnly:true})
        }
    }
about 4 years ago · Santiago Trujillo
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!