Learn Introductory JavaScript by Building a Pyramid Generator - Step 71

Tell us what’s happening:

My code is:
if (true); {
console.log(“Condition is true”);
}
This code didn’t pass and the comment after the test is:
Your if body should log “Condition is true”.
I think this is what I did, and the required result is already logged. So, I don’t know what is wrong in the if body.

Your code so far

const character = "#";
const count = 8;
const rows = [];

function padRow(rowNumber, rowCount) {
  return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}

// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
  rows.push(padRow(i, count));
}*/


// User Editable Region

if (true); {
  console.log("Condition is true");
}

// User Editable Region


let result = ""

for (const row of rows) {
  result = result + "\n" + row;
}

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 71

Hello! Try removing the semi-colon after the condition here. I believe your code will pass then.

Yes, I did that and the code passed. Thank you.

1 Like

You are welcome!

Happy coding!