현재 결과물 


코드

<!DOCTYPE html>
<html>
<head>
    <title>Document</title>
    <style>
        h1 {
            text-aligncenter;
        }
        div {
            floatleft;
            width100px;
            height100px;
            text-aligncenter;
            line-height100px;
            background-colorpink;
            border-radius50px;
            margin20px;
        }
    </style>
</head>
<body>
    <script>
        var lotto =[];
        document.write("<h1>로또 번호 출력하기</h1>");
        for(var i=0i<6i++) {
            var num = Math.floor(Math.random()*44)+1;
            for (var j in lotto) {
                if (num == lotto[j]) {
                    num = Math.floor(Math.random() * 44) + 1;
                }
            }
            document.write("<div>" + num + "</div>")
            lotto.push(num);
        }
       
    </script>
</body>
</html>

실습하면서 만든건데 

공 6개를 따로따로 떨궈놓으려고 했지만 도통 안되서 물어봄 


그리고 또 하나 질문함 

이거 다른 사람이 가르쳐줄 땐 이해가 좀 갔지만 지금 생각하려니 이해가 안됬던거

  num = Math.floor(Math.random() * 44) + 1;
                }
            }
            document.write("<div>" + num + "</div>")
            lotto.push(num);
        }
       
    </script>

스크립트 안의 docomemt.write("<div>" + num + "<div>") 테그가 왜 저 위치에 있어야해? 

애초에 내가 while이나 for문 올 때마다  div를 스크립트의 어느 부분에 써야하는지 늘 잘 몰라서 수업에서도 많이 해매는 편임

조건문 반복문 있는 스크립트에 div 넣을때 어떤 위치에 넣어야 하는지 좀 알려주라 제발