더북(TheBook)
let clickable = true;
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;
    if (diff === 2 || diff === -1) {
      console.log('승리');
    } else if (diff === -2 || diff === 1) { 
      console.log('패배');
    } else { 
      console.log('무승부');
    }
    setTimeout(() => { 
      clickable = true;
      intervalId = setInterval(changeComputerHand, 50);
    }, 1000);
  }
};
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.