What would be the best way to make this a conditional for loop.

var type_of_loop_single = 1
// var type_of_loop_double = 2

var rows = grid.get_rows();
for (var i = 0; i < rows.get_length() ; i++) {
var row = rows.get_row(i);
for (var j = 0; j < row.get_cellCount() ; j++) {
var cell = row.get_cell(j);
}
}

If the type of loop is 1, then I do want to use the i and j variables to loop through. If the type of loop is 2, then I want the i variable to work the same way, but I will name the j variable like this:
var cell = row.get_cellByColumnKey(myColumnName)

What would be a good way to structure this?