[For loop] Build a pyramid with Asterisk(*)

황희윤·2021년 7월 29일
0

Today, I learned what for loop is and how handy it is. I made simple multiplication table, but I wanted to do further more using for loop. Therefore, I tried to make an alert showing a pyramid.

I referred to the website https://recoveryman.tistory.com/29

I built a pyramid with asterisk(*) inside alert using Javascript for loop.


This is how I wrote the code to build a pyramid

As you can see, there is for loop and it has three for statements.
The first statement is used to write 'reverse for loop', so I can make the space on the side of asterisk line.
The second statement add spacing to avoid every asterisk sticks to the left.
The third statement puts asterisk.


This is the image of the pyramid I made.

It was very difficult challenge. I still don't fully understand even if I searched on Internet and looked at Javascript books. I need to study more and hope to figure out how this works.

profile
HeeYun's programming study

0개의 댓글