10 Stars Challenge - Alternate solution (Warning solution is in this post, dont open if you haven't solved)

Just thought I’d share a different solution to the 10 Stars challenge. It works and I didn’t have to use a nested for-loop.

function showStars(rows) {
  let stars = "";
  for (let i = 1; i <= rows; i++) {
    if (i <= rows) {
      console.log((stars += "*"));
    }
  }
}

showStars(6);