Learn Introductory JavaScript by Building a Pyramid Generator - Step 113

Tell us what’s happening:

How can i not use comparoson operators to check if inverted is true?

Your code so far

const character = "#";
const count = 8;
const rows = [];
let inverted = true;

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

// TODO: use a different type of loop

// User Editable Region

for (let i = 1; i <= count; i++) {
if (inverted  true)
  rows.unshift(padRow(i, count));
}

// User Editable Region


/*while (rows.length < count) {
  rows.push(padRow(rows.length + 1, count));
}*/

/*for (let i = count; i > 0; i--) {
  rows.push(padRow(i, count));
}*/

let result = ""

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

console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 113

Have you completed a lesson about truthiness?

I dont think so is it the one about falsy and thruthy values?

Yes. The lesson about falsy and truthy is what I mean.

Did you need anything other than the value of the variable in that lesson?

I dont remember well…

Luckily, you don’t have to memorize stuff and can use a search engine for a question like ‘JS truthy if statement’

No i checked i just changed the condition to falsy values what should i do

I am not sure what you changed. Can you post your new code please?

for (let i = 1; i <= count; i++) {
if (inverted  = true);
  rows.unshift(padRow(i, count));
}

This is not how you treat a value as truthy or falsy. Where did you look up how to use the idea of truthy or falsy? You seem to have misunderstood what you read.

I just went back to the lesson i learnt that in

Ok, which lesson was that? Do you have a link?

It was lesson 81. …

Do you have a link? There are many lessons numbered 81

Ok, I don’t see anywhere in there that used a = inside of the condition for the if statement. Why did you add that =?

Bcs in the nest lessons they explained that either but i asked a few friends and they helped thanks either way

I was trying to check if inverted was false
But i forgot that they just treat variables like booleans

that’s exactly what using the truthiness and falsiness of a value is

anyway, be careful with =, remember that it is the assignment operator, not a comparison operator

try inverted == true instead of just leaving an empty space such that it is:
MOD EDIT: SOLUTION REMOVED