To create a triangle below, we can use function and loops in JavaScript.

* 
* * 
* * * 
* * * * 
* * * * * 
* * * * * * 
* * * * * * * 
* * * * * * * * 
* * * * * * * * * 
* * * * * * * * * *

 

See the Pen Build a Triangle by Ziqi Zhou (@IannaZhou) on CodePen.