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

**URL:** <https://forum.codewithmosh.com/t/10-stars-challenge-alternate-solution-warning-solution-is-in-this-post-dont-open-if-you-havent-solved/7691>\
**Category:** JavaScript\
**Created:** [October 2, 2021, 12:54am UTC](https://forum.codewithmosh.com/t/10-stars-challenge-alternate-solution-warning-solution-is-in-this-post-dont-open-if-you-havent-solved/7691 "2021-10-02T00:54:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonymoreno86](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/tonymoreno86/32/2281_2.png) [@tonymoreno86](https://forum.codewithmosh.com/u/tonymoreno86)\
**Post date:** [October 2, 2021, 12:54am UTC](https://forum.codewithmosh.com/t/10-stars-challenge-alternate-solution-warning-solution-is-in-this-post-dont-open-if-you-havent-solved/7691/1 "2021-10-02T00:54:31Z")

</div>

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.

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

showStars(6);

```
