Learn Introductory JavaScript by Building a Pyramid Generator - Step 41

Tell us what’s happening:

You should concatenate row to your result variable.

Your code so far

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

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

}

let result = ""
result = row + "marks"

// User Editable Region

for (const row = + result    of  rows ) {
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/125.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 41

Please talk to us about how those instructions are confusing for you. Communication is a critical professional programming skill

2 Likes

Welcome to the forum @mabubakarsiddiq11

Here is a comparison of the original code and your code.

The code in red is the original code, the code in blue is your code.
The code in magenta is the overlap.

image

You appear to have modified the for …of loop.

This is why you have the following message in the console.

image

Also the three dots indicate you have an undeclared variable on line ten.
image

Please reset the step to restore the original code. Then in the body of the loop add the required code. Make sure you refer to the example given in the instructions.

Happy coding

Reset your code, you have made multiple changes you were not asked to make.


The only code you will be writing is inside the for...of loop.

for (const row of rows) {
  // inside for...of
}

Look at the concatenation example given, here is a more complete version.

let hello = "Hello";
hello = hello + " World";

console.log(hello); // Hello World

row is each number in the rows array, so 0 to 7, result is an empty string.

Inside the loop, add result and row together using + (concatenate) and assign the result of the concatenation back to result.

Example:

const letters = ["H", "e", "l", "l", "o"];
let word = "";

for (const letter of letters) {
  word = word + letter;
}

console.log(word); // Hello
2 Likes

I just want to say, if your code is exactly the same as tutroial videos but still doesn’t pass, try switching browsers. (I’ve had it happen a few times where switching from Chrome to Safari made the same code pass on Safari.)