Building Pyramid Generator

Hi gents,

kindly assist…am kind stuck in this step and am missing something

Step 37

Remember in your previous loop that you used the addition operator + to increase the value of i by 1.

You can do a similar thing with a string value, by appending a new string to an existing string. For example, hello = hello + " World"; would add the string " World" to the existing string stored in the hello variable. This is called concatenation.

In your for...of loop, use the addition operator to concatenate the row value to the result value.


const count = 8;

const rows = [];

for (let i = 0; i < count; i = i + 1) {

rows.push(i);

}

let result = ""

for (let row of rows) {

result = rows +" row";

}

console.log(result);```

you have a variable row, so here why you have a string?

Hi Ilenia,

Thanks for your feedback.

I was looking at my code after seeing your reply, but I still don’t see light…

Could you kindly put it in another perspective?

1 Like

can you explain to me what this step wants you to do?

Well what I understand is that the value of “row” should be added to the “result” one…

Where is the "row" string in the instructions?
@Siquela

the value of row, yes, not the string "row"

row is a variable. On each loop iteration, the row variable is assigned the currently iterated element from the rows array.

const names = ["Alice", "Bob", "Charlie"];

for (const name of names) {
  console.log("Hello, " + name);
}

You use the variable like you use any other variable, by its identifier (its name).

solution is ===>

Mod edit: removed

@devrimq

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.

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.