Javascript - Stars exercise

While I understand why it is solved the way it is with nested for loops, this is the solution I put together:

showStars(5);

function showStars(rows) {
for (let row = 0; row <= rows; row++)
if (row)
console.log(’*’.repeat(row));
}

‘if row’ is just to stop the initial blank from the row = 0; otherwise, it produces the same result.

So why are you starting your loop with row 0 anyway? You could start with row 1 and don’t need that if anymore.

And BTW: Read about how to format code in the forum.

Honestly, I just didn’t want to start with row = 1. What if someone entered 0 into the function or anything that was not a number? That was my initial thought, but I later realized it would not print anything to the terminal in those cases. I checked out the formatting link and will be sure to do so in future.