0

I want to create a square pattern with for loops.I managed to create rows but the columns went under the rows,how to fix that?

https://code.sololearn.com/WFsMiVDnVXf6/?ref=app

25th Dec 2022, 5:30 PM
JŌẞlÔX™
JŌẞlÔX™ - avatar
2 odpowiedzi
+ 1
Simple way: Take a string variable and add "*" to it in loop. . After the loop display string. console.log() adds new line character after output so goes to next line..
25th Dec 2022, 6:10 PM
Jayakrishna 🇮🇳
0
u can use either: 1- repeat method: let nrows = 5 for(let i=1;i<=5;i++){ console.log('*'.repeat(nrows)); } 2- joining an array: let nrows = 5 for(let i=1;i<=5;i++){ console.log(Array(nrows+1).join('*')); }
25th Dec 2022, 6:10 PM
Ervis Meta
Ervis Meta - avatar