Inflearn brand logo image

Inflearn Community Q&A

parkbuhyeon06112201's profile image
parkbuhyeon06112201

asked

[Renewal] Introduction to JavaScript in Zero Seconds through Coding Self-Study

Improving readability with async/await

setTimeout 관련 질문

Written on

·

271

0

아래 사진처럼 6개의 공의 값이 출력이 안되는데 도무지 이유를 모르겠습니다 ㅠ 

for (i = 0; 7 > i; i++) {
	if (i === 6) {
		console.log(bonus)
		setTimeout(() => {
			const $ball = document.createElement('div');
			$ball.className = 'ball';
			$ball.textContent = bonus;
			$bonus.appendChild($ball);
		}, (i + 1) * 1000);
	} else {
		console.log(winBalls[i])
		setTimeout(() => {
			const $ball = document.createElement('div');
			$ball.className = 'ball';
			$ball.textContent = winBalls[i];
			$result.appendChild($ball);
		}, (i + 1) * 1000);
	}
}

javascript

Answer 1

1

zerocho님의 프로필 이미지
zerocho
Instructor

let i = 0이어야 합니다. let 안붙이면 var입니다.

바로 다음 강의(블록, 함수 스코프, 클로저 문제)를 듣고 완벽하게 이해했습니당 !! 답변 감사합니당 ~

parkbuhyeon06112201's profile image
parkbuhyeon06112201

asked

Ask a question