Duplicate some rows in a sheet range using google apps script

I have a dictionary in my script of key -> {list of values}

I have a sheet which with these headers:

key, name

I want to go over a range in a sheet and add rows of the values.

say:

k1 -> val1, val2

k2 -> val3

and:
enter image description here

I saw this post

The problem is that while iterating I change the range.
How can I do it efficiently?

    var rangeValues = searchRange.getValues();
  // Loop through array and if condition met, add relevant
  // background color.
  for ( i = 0; i < lastColumn - 1; i++){
    for ( j = 0 ; j < lastRow - 1; j++){
      var kw_data = kw_to_label[rangeValues[j][i]];

Source: Ask Javascript Questions

LEAVE A COMMENT