'How to print the data of an array into a Google sheet with Google Apps Script

So I have got this array that is called sourceData that contains elements and each element has 10 values so basically i want to print 252 rows and each row has a value in the cell (10 cells) starting from row 3. So what I did is that I created a for loop but its not working and its printing the week number "370" (which is the first value of the array) instead, and it was printed 503 times.

I also think that creating a for loop is going to take too long to print the data since there is a big number of data, so was wondering if there is a code that would be better than that one .

var sourceData =sourceData.sort(function(a,b){ return a[2] > b[2] ? 1 : -1; });
  sourceData = sourceData.reverse()
  
  for(let x=3; x<sourceData.length+3; x++){//   x is number of the row
  var y=0;
  thisSheet.getRange(parseInt(x),1 ,sourceData.length,10).setValue(sourceData[y]);
  y++;

I'm not gonna include the code how i got the sourceData since I dont think it's necessary

If you need more explanation please let me know.

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source