//배열의 끝까지 찍는 코드
/*
const ar = [10, 20, 30, 99, 40, 50];
for (let i = 0; i < ar.length; i++)
{
if (ar[i] === 99)
{
break; // for문을 빠져나가서 아래쪽 console 코드로 이동 루프를 나감
}
else
{
console.log(ar[i]);
}
}
console.log(aaa);
*/
//continue
const ar = [10, 20, 30, 99, 40, 50];
for (let i = 0; i < ar.length; i++)
{
if (ar[i] === 99)
{
continue; // 루프 맨위로 이동 i++증가값으로 넘어가
}
console.log(ar[i]);
}
console.log(aaa)
//2단 continue
let dan = 2;
let mul = 1;
for (let i =0; i < 9; i++, mul++)
{
if (mul === 6) // (mul !== 6)시 contunue생략가능
{
continue;
}
console.log(` ${dan} x ${mul} = ${dan * mul}`);
}
</script>
/*
for (let i = 0; i < 10; i++){
for (let j = 0; j <= i; j++)
{
console.log('*')
}
console.log(\n);
}
*/
let stars = '';
let starCount = 1;
for (let line = 0; line < 10; line++)
{
//별의 갯수를 설정한다.
for (let k = 0; k < starCount; k++)
{
stars += '*'; //stars = stars + '*';
}
//별을 로그에 찍는다.
console.log(stars);
//별을 html 문서에 찍는다.
document.body.innerHTML += stars;
document.body.innerHTML += '<br>';
starCount++;
stars = ''; //변수 초기화
}