I need help creating a pyramid with odd numbers for edges. The desired output should look like this:
.......5
...3,4,3
1,2,3,2,1
(dots are simply for formatting)
So far, I have written the following code:
function p(n){
let string = "";
for (let i = 1; i <= n; i++) {
for (let j = 1; j <= n - i; j++) {
string += " " ;
}
for (let k = 1; k <= 2*i-1; k++) {
string += n-k +1;
}
string += "\n";
}
console.log(string);
}
p(5);
However, I'm unsure about how to proceed in order to achieve the intended result.