1 year ago
#386276
Stacey
Drawing stars with nested loop javascript
I need to write porogram that will draw starslike below using nested depend loops:
*
**
***
****
*****
I wrote code below and it works in console but in test I receive information:You have not used nested and dependent(!) for loops. Can you help and explain what I'm doing wrong?
const n = 5
let stars = "";
for (let i = 0; i < n; i++) {
stars = "";
for (let j = i; j < n; j++) {
stars = "*" + stars;
}
console.log(stars);
}
javascript
loops
nested
0 Answers
Your Answer