Learn Introductory JavaScript by Building a Pyramid Generator - Step 82

Tell us what’s happening:

I dont undertand exactly what it would like for me to do it says create an else if stateent to check if 5 is less than 10 and i put that in or can someone tell me what im doing wrrong?

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 ("") {
  console.log("Condition is true");
} 
  /
}else if ("5 is less than 10"){
 // code to run if 5 is less than 10 is true
}
  (console.log("5 is less than 10")

// 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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 82

the else if statement must be added to the end of your if block similar to this:

if () {
} else if () {
}

Also to check if a number is less than a number you must compare the numbers with a <

I’ve done that but it still says the else if statement should check if 5 is less than 10?

in your code above you did not do that correctly.
Did you make any corrections?
Please share the new code if yes. If you haven’t made any changes, please let us know what we can explain better to you.

if (“”) {
console.log(“Condition is true”);
}else if (“5 < 10”){
console.log(“5 is less than 10”)
}

is this version correct?

That is much better!

Right here though, take away the double quotes. You should only have double quotes around strings and 5 and 10 are numbers.

Thank you ive been stuck on this for a while :sob:

you did great! Try to practice what you are learning by writing out more if statements just for fun!

1 Like