Tell us what’s happening:
I did everything and I have finished the code. It’s not working what’s wrong???
Your code so far
function pyramid(str, row, bool) {
let rows = [];
function padRow(rowNumber, rowCount){
return ( ' '.repeat(rowCount - rowNumber) + str.repeat(2 * rowNumber - 1) + ' '.repeat(rowCount - rowNumber));}
for (let i = 1; i <= row; i++){
if(bool === false){
rows.push(padRow(i, row));
} else{
rows.unshift(padRow(i, row));
}
}
let result = "";
for (let row of rows) {
result =result + row + '\n';
}
return '\n' + result + '\n';
}
console.log(pyramid("o", 4, false));
console.log('"\n o\n ooo\n ooooo\nooooooo\n"')
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator