더북(TheBook)
const clickButton = (event) => { 
  if (clickable) {
    clearInterval(intervalId); 
    clickable = false;
    const myChoice = event.target.textContent === '바위' ? 'rock' 
      : event.target.textContent === '가위' ? 'scissors' : 'paper';
    const myScore = scoreTable[myChoice];
    const computerScore = scoreTable[computerChoice]; 
    const diff = myScore - computerScore;
    let message;
    if ([2, -1].includes(diff)) { 
      score += 1;
      message = '승리';
    } else if ([-2, 1].includes(diff)) { 
      score -= 1;
      message = '패배';
    } else {
      message = '무승부';
    }
    $score.textContent = `${message} 총: ${score}점`;
    setTimeout(() => { 
      clickable = true;
      intervalId = setInterval(changeComputerHand, 50);
    }, 1000);
  }
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.