Skip to content
Advertisement

How to make a triangle using for loop javascript

I have a simple question although i cannot manage to resolve this problem. Hope you can help. I need to make triangle using for loop and from this 4 exercises I don’t know what to do with the third one. I haven’t used Javascript before, so any help would be appreciated.

enter image description here

JavaScript

JavaScript

This is code I wrote for D in photo. And I’m sorry i did not add it at first.

Advertisement

Answer

I’m sure there are better solutions (simply left-padding with spaces comes to mind), but here’s the quick and dirty one I created from your own solution.

JavaScript

https://js.do/code/diamondsinthesky

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement