더북(TheBook)
const $form = document.querySelector('#form');
const $result = document.querySelector('#result');
const $bonus = document.querySelector('#bonus');
function drawBall(number, $parent) {
  const $ball = document.createElement('div');
  $ball.className = 'ball';
  $ball.textContent = number;
  $parent.appendChild($ball);
}
const setTimeoutPromise = (ms) => new Promise((resolve, reject) => {
  setTimeout(resolve, ms);
});
$form.addEventListener('submit', async (event) => {
 (중략)
 console.log(winBalls, bonus);
  for (let i = 0; i < winBalls.length; i++) {
    await setTimeoutPromise(1000);
    console.log(winBalls[i], i);
    drawBall(winBalls[i], $result);
  }
  await setTimeoutPromise(1000);
  drawBall(bonus, $bonus);
});
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.