Learn Introductory JavaScript by Building a Pyramid Generator - Step 42

Tell us what’s happening:

I need help with concatenation. It’s a lot harder than I thought.

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) {

}

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 42

1 Like

Hi @coding_kid13 ,

Concatenation means appending a new string to an existing string.

For example:

We start with result as an empty string:

let result = "";

We concatenate letter "A" to result:

result = result + "A";

Now, result is "A".

We continue to concatenate letter "B" to result:

result = result + "B";

Now, result is "AB".

That’s called concatenation.


Now, the instruction asked us to:

concatenate row to result inside the for loop

What should we do?

1 Like

I tried mod edit: code removed and it worked! Thanks!

1 Like

Thanks great answer! work for my code! Have great day!

1 Like

Why does it not accept result = result + “row”; ?

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.