Is there a way to create a pyramid number structure in JavaScript?
for (i = 1; i <= 5; i++) {
var k = ' ';
var myspace = '';
for (j = 0; j < i - 0; j++) {
k += i;
myspace += ' ';
}
console.log(myspace + k);
}
I am trying to achieve this kind of pattern:
1
2 2
3 3 3
4 4 4 4