var h=5;
for(var i=1;i<=h-1;i++){
for(var j=h-1;j>=i;j--){
document.write(" ");
}
for(var n=1;n<=2*i-1;n++){
document.write("*");
}
document.write("<br>");
}
How does this code run? I can understand this code, but I am confused by its operation. The more I think about it, the less I understand how it operates. I am a newbie, please give me some detailed advice. Thank you very much. Thank you. Thank you
Enter the outer for at first, then the first for in the inner layer, then the second for in the inner layer, and then the first round of loop ends.
First round output:
    *<br>
Second round output:
   ***<br>
Third round output:
  *****<br>
Fourth round output :
 *******<br>
The first loop of the outer layer: four spaces and a new line
Second outer loop: three spaces, three line breaks
The third outer loop: two spaces, five line breaks
....
Execute in order, enter the outer loop, and then execute the following loop after the inner loop loops
You can take a look at the basic syntax of the for statement and calm down and think about it. The outer loop determines the number of line breaks, and the two inner loops determine the number of spaces and * symbols respectively.
The loops inside are independent and proceed almost simultaneously