JavaScript mengubah warna berdasarkan nilai kunci di setiap objek array

function buildProjectsGrid(data) {
    let lastName = data[0]?.Name;
    let rowState = false;
    return data.map((obj) => {
      if (lastName !== obj.Name) {
        rowState = !rowState;
        lastName = obj.Name;
      }
      const colorClass = rowState ? 'red' : 'blue';
      ...
SAMER SAEID