Create star patterns with loops
Let's start with the simplest pattern: a right triangle where each row has one more star than the previous row.
for (let i = 1; i <= 5; i++) {
let stars = ""
for (let j = 1; j <= i; j++) {
stars += "*"
}
console.log(stars)
} j <= iYou can also use the repeat() method:
for (let i = 1; i <= 5; i++) {
console.log("*".repeat(i))
}