function onLeftClick(event) { // 좌클릭 동작
      const target = event.target; // td 태그
      const rowIndex = target.parentNode.rowIndex;
      const cellIndex = target.cellIndex;
      const cellData = data[rowIndex][cellIndex];
      if (cellData === CODE.NORMAL) { // 닫힌 칸이면
        const count = countMine(rowIndex, cellIndex); // 주변 지뢰 개수
        target.textContent = count || ''; 
        target.className = 'opened'; // 열린 칸으로
        data[rowIndex][cellIndex] = count;
      } else if (cellData === CODE.MINE) { // 지뢰 칸이면
      } // 나머지는 무시
    }
    function drawTable() {
      data = plantMine();
      data.forEach((row) => {
        (중략)
        $tbody.addEventListener('contextmenu', onRightClick); // 우클릭 이벤트 등록
        $tbody.addEventListener('click', onLeftClick); // 좌클릭 이벤트 등록
      });
    }
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.