Analysis of checking a draw in the tic-tac-toe game in JavaScript

Let's now consider a draw. Obviously, a draw occurs if all cells are filled and there is no winner. Let's do it:

javascriptfunction start(cells) {
  let i = 0;
  
  for (let cell of cells) {
    cell.addEventListener('click', function step() {
      this.textContent = ['X', 'O'][i % 2];
      this.removeEventListener('click', step);
      
      if (isVictory(cells)) {
        alert(this.textContent);
      } else if (i == 8) {
        alert('draw');
      }
      
      i++;
    });
  }
}