Learn Introductory JavaScript by Building a Pyramid Generator - Step 43

Tell us what’s happening:

The answer I have given I believe is correct and for some reason I am still getting an error… Can anybody take a look at this? Maybe this question is bugged because im 90% sure I did this right.

Your code so far

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

for (let i = 0; i < count; i = i + 1) {
  rows.push(i);
}

let result = ""


// User Editable Region

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

// User Editable Region


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/133.0.0.0 Safari/537.36 Edg/133.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 43

Please share any errors or hints you are getting. This is often key to solving the problem.

Use a second addition operator to append a new line after the result and row values.

After, not in between.

Yes absolutely,

// running tests 2. You should concatenate your row variable to your result variable.

  1. You should concatenate the \n escape sequence to your row variable.

  2. You should assign the entire concatenation back to your result variable.

It lists the numbers for me from top to bottom instead of left to right.

I have also tried to not use “\n” and just plain \n

[quote=“lambertd586, post:3, topic:736209”]
You should concatenate the \n escape sequence to your row variable.
[/quote]

Does this mean to add it to the beginning or end of the row variable?

Im sorry if I was unclear, let me try again.

It tells me to Use a second addition operator to append a new line after the result and row values.

My code: result = result + “\n” + row;

I just figured it out thanks for the tips. My problem was row and "/n’ were in the wrong spots.

1 Like

notice it says “after”
did you put it after the row variable?