Hello! need to make just such a pyramid on JS

1 22 333 4444 55555 666666 7777777 88888888 999999999 

wrote such code

 for(var i = 1;i <= 9; ++i) { for(var j = 1; j <= i; ++j) { document.write(' '+j+' '); } document.write('<br>'); }; 

And I can not figure out how to loop the numbers inside each line. I will be grateful for the help

  • don't do document.write - zb

1 answer 1

Output the current i j times and everything will turn out

 for (var i = 1; i <= 9; ++i) { for (var j = 1; j <= i; ++j) { document.write(' ' + i + ' '); } document.write('<br>'); }; 

  • thank!!! you saved my life =)))))) - ObiVan