for each (var entity in nlData.entities) { code example

Example: for each (var entity in nlData.entities) {

ss.toast('Analyzing entities and sentiment...');
  for (var i = 0; i < numRows; ++i) {
    var value = values[i];
    var commentEnCellVal = value[translationColumnIdx];
    var entityCellVal = value[entityColumnIdx];
    var reviewId = value[idColumnIdx];

    // Calls retrieveEntitySentiment function for each row that has a comment
    // and also an empty entity_sentiment cell value.
    if (commentEnCellVal && !entityCellVal) {
      var nlData = retrieveEntitySentiment(commentEnCellVal);
      // Pastes each entity and sentiment score into Entity Sentiment Data sheet.
      var newValues = [];
      var entities = nlData.entities;
      entities.forEach(function(entity) {
        var row = [reviewId, entity.name, entity.salience, entity.sentiment.score,
          entity.sentiment.magnitude, entity.mentions.length,
        ];
        newValues.push(row);
      });
      if (newValues.length) {
        entitySheet.getRange(entitySheet.getLastRow() + 1, 1, newValues.length,
            newValues[0].length).setValues(newValues);
      }
      // Pastes "complete" into entity_sentiment column to denote completion of NL API call.
      dataSheet.getRange(i+1, entityColumnIdx+1).setValue('complete');
    }
  }
};