Tell us what’s happening:
I have a problem, my program build pyramid as it needs in task but didnt acept my solution.
Your code so far
function pyramid(symbols, rows, side) {
let row = "";
let symbolsTotal = rows * 2 - 1
let spaceLeft = rows;
let spaceRight = rows;
if(side == true) {
for (let i = rows; i > 0; i--) {
let newRow = "";
if(i == rows){
newRow = `${symbols.repeat(symbolsTotal)}`;
row += newRow;
}else{
newRow = `\n${" ".repeat(spaceLeft - i)}${symbols.repeat(symbolsTotal - (spaceLeft - i) - (spaceRight - i))}`;
row += newRow;
}
}
}else{
for (let i = 0; i < rows; i++) {
let newRow = "";
newRow = `\n${" ".repeat(spaceLeft - i - 1)}${symbols.repeat(symbolsTotal - (spaceLeft - i - 1) - (spaceRight - i - 1))}`;
row += newRow;
}
}
return row;
}
console.log(pyramid("o", 4, false));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator