ConfirmIt 3D Grid pipe answers

Pipe the values of two different columns in a 3D grid for each of the its rows.

//surveyscripting.com

function ageRelation()
{
  var qName = 'q1';
  var z = '';
  var r : int;
  var j : int;

  for (var i = 1; i <= 8; ++i) {
    if ( f(qName+'_1')[i].toBoolean())
    {
      r = i + 1;
      z += f(qName+'_1')[i].label()+" grandson";
      if ( f(qName+'_1')[r].toBoolean())
      {
        z += ', ';
      }
    }
  }
  for (var k = 1; k <= 8; ++k) {
    if (f(qName+'_2')[k].toBoolean())
    {
      j = k + 1;
      z += f(qName+'_2')[k].label()+" granddaughter, ";
    }
  }
  return z;
}