for문을 공부할 때 다들 한번 쯤 해보셨을 별찍기 예제 입니다.
//삼각형 찍기
for(let i = 0; i < 5; i++){
let str = "";
for(let j = 0; j <= i; j++){
str = str + "*";
}
// str += "\n"
console.log(str) // *, **, ***, ****, *****
}
//역삼각형 찍기
for(let i = 5; i >= 1; i--){
let str = "";
for(let j = 1; j <= i; j++){
str = str + "*";
}
// str += "\n"
console.log(str) // *****, ****, ***, **, *
}