Learn Introductory JavaScript by Building a Pyramid Generator - Step 42

Tell us what’s happening:

I’ve been stuck here for a while now. I understand I have to assign the result of my concatenation to my result variable but I can’t seem to figure out how. I’ve looked through the forum with people having the same issues but still couldn’t figure it out. If anyone could help, that’d be amazing!

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) {
 row = row + result;
}

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 42

Do you get a hint or error message in the console?

it mentioned that my row variable was “read-only” but that doesn’t make sense because I’ve just been following the instructions

Any other hints or other messages?

Welcome to the forum :wave:

just that I should assign the result of my concatenation to my result variable which I can’t understand how to do

That is a useful message, although it would be nice if it was in the instructions, right?

Currently where are you assigning the result of the concatenation?

in the body of my for…of loop, I’ve written row = row + result which is based off the example

So you are assigning the concatenation to the row variable (which you can’t really do because it’s a const (constant) and so not writable)

This is the assignment operator: =

Oh, should I should try assigning it to my result variable?

1 Like

I was also stuck for a long time and got the issue resolved . Try to concatenate the row to the result.

code removed by moderator

hi @Rayzack1

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.