Understanding calling a function within a loop

I was hoping some of you could help me in understanding a snippet of code I have been doing some practice with. In another one of my resources to learn code, we are using functions and loops to print out a triangle shape of the # symbol. The code looks like this.

function createTriangle (height) {

for (var i = 1; i <= height; i++) {
var row = ‘’;
for (var j = 1; j <= i; j++) {
row += ‘#’;
}
console.log(row);
}
}
createTriangle(7)

Once executed, it then prints out one of the first line, 2 on the second, so on until 7. From my understanding, we are using a function and passing a number value of 7 to call that function towards the end. The loops are used to loop through the code to print out the triangle, but that is the part im hazy on. And the reason for two loops.

Just trying to seek a little clarification. If anyone has a moment to help me understand this, would really appreciate it.

Thanks alot!

As always thank you very much randell