I have spreadsheet with student names, ages and test scores.
I want to loop through the 4th column (student ages) which has already been sorted from lowest to highest.
The loop notes the age of the first and youngest student in cell "D1" but I want it to stop looping when it hits on a cell where the student's age is 4 years older than the student in "D1" e.g:
11 (Cell "D1")
11
11
12
12
13
14
15 (As this student is 4 years older than cell "D1", I want it to return "D6".

I would then like to repeat the process with "D6" (or whatever the cell reference will be) now being the initial starting point and returning the cell when it hits on a cell when the student is 4 years older.

Here is what I have done already. I'm really new to this, so let me apologise in advance! Any help would be appreciated as I'm really stuck.

```
    function myFunction() {
  var app = SpreadsheetApp;
  var activeSheet = app.getActiveSpreadsheet().getActiveSheet();
  var firstAge = activeSheet.getRange("D1").getValue()
  var lastRow = activeSheet.getLastRow();

  for(var i=1;i<lastrow+1;i++){
      var column4 = activeSheet.getRange(i, 4).getValue();

          if (column4 === firstAge + 4) {
            activeSheet.getRange().getRowIndex(column4);

```