formulas – Modify contents of an array using an IF statement in Google Sheets?

How do I modify contents of an array if it matches a condition?

Right now I have

var data = sheet1.getRange(2,1,3,2).getValues();
var key = sheet2.getRange("A2").getValue();
//
    if (data(i)(1) == key) {
      //Change Value of that Cell
 }
}

How would I change or append the matched cell(s)?