Learn Introductory JavaScript by Building a Pyramid Generator - Step 42

Tell us what’s happening:

The prompt asks to concatenerate “row” to the results variable, from the information given, it seems this is how its done. Is there anything wrong with this code?

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 + "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/130.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 42

you need to concatenate the row variable, not a string "row"

Whats the row variable. Is it given in the tutor prompt?

you have written it in a previous step

But the step is asking to append a new string

It’s asking to

use the addition operator to concatenate the row value to the result value.

It doesn’t ask to append a new string

I thought thats the meaning of concatenate

concatenate means merging two strings together, the two strings are row and result

If we are concatenating ‘row’ to ‘result’ , then shouldn’t it look like this?:
for (const row of rows) {
result = result + “row”;

}

no, because you need to concatenate the value of the row variable, not a "row" string

But there is no row value in the code as at this step

you created it in the previous step

I thought creating a row value would be something like "let row = ’ '; " or “const row = ’ ';”

it’s also that. The row variable is the loop variable, created with const row of rows (see, there is const there!)

Im still not sure what this row value is…

for each iteration row is a different value of the rows array.

You can visualize the code execution with this code: Online JavaScript Compiler, Visual Debugger, and AI Tutor - Learn JavaScript programming by visualizing code

I know, but since there was no value given, doesn’t that mean that ‘row’ is the new string to be concatenated to result?

you need to concatenate row to result so that the value inside row is concatenated, you should not concatenate the literal string "row"

But there is no value for row, unless you mean this:

for (const row of rows) {
result = result + “const row”;

}

row variable is just created, it’s not have any value yet. But you have written row of rows. rows have an array as a value.