Google Apps Script でシートの情報の同期する

function onEdit(event) {
  var index = 0; 
  var sheet = SpreadsheetApp.getActive().getSheetByName(event.source.getSheetName());
  var rowData = sheet.getSheetValues(event.range.getRow(), 1, 1, sheet.getLastColumn());

  var master = SpreadsheetApp.getActive().getSheetByName('master');
  var masterData = master.getSheetValues();

  for (var i = 0; i < masterData.length; i++) {
    if (masterData[i][index] === rowData[0][index]) {
      var range = master.getRange(i + 1, 1, 1, master.getLastColumn());
      range.setValues(rowData);
      break;
    }
  }
}