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);
});