Learn Introductory JavaScript by Building a Pyramid Generator - Step 22

Tell us what’s happening:

array[array.length -2] = 10rows;
Hello. There is something wrong with my code, but I don’t understand what? Please, help me.

Your code so far

let character = 'Hello';
let count = 8;
let rows = ["Naomi", "Quincy", "CamperChan"];
console.log(rows[0]);

// User Editable Region

array[array.length -row] = rows;

// User Editable Region

console.log(rows);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 OPR/114.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 22

Hi @Dennis-code153

  1. You should subtract 1from the length in your bracket notation.

Your code is subtracting row instead.

The hint message will guide you on the next part.

Happy coding

rows[2-1] = 1;

I’ve done it, but it doesn’t pass.

now you don’t have the length of the array anymore. The length was fine, the issue was on the right of the substraction operator. Now the issue is on the left of the subtraction operator.

array[2] = 9;
array[array.length -row] = rows;
array[array.length -row] = 10;

I’ve tried all these varients, but they don’t work.

do not put row there, you need to substract 1, not row
also the name of the array is rows, change array into rows

array[rows.length-1] = Naomi;

It isn’t working either.

you still have array at the beginning of the line.
Also you need to assign 10, not Naomi

You can review how to work with arrays here:
https://www.w3schools.com/js/js_arrays.asp

const cars = ["Saab", "Volvo", "BMW"];
cars[0] = "Opel";
array[array .length-1] = 10;

This variant doesn’t pass either.

it should be rows not array. Please stop reverting things you already fixed

array[rows.length-1] = 10;

It isn’t passing, what else?

let rows = ["Naomi", "Quincy", "CamperChan"];

I’ve tried to use this example, but it doesn’t work in this case. No one name from the row passes right.

How would you print “Naomi” from the rows array?

const cars = ["Saab", "Volvo", "BMW"];
console.log(cars[0]);

output:
"Naomi" EDIT: This should be "Saab"

I’ve tried not only Naomi, other names are also not passing.

How would you print “Naomi” from the rows array? Show me

Don’t worry about passing the test for now, you aren’t close to there yet.

let rows = ["Naomi", "Quincy", "CamperChan"];

How would you print “Naomi”?

console.log(Naomi)
Isn’t it right?

Nope.

You are already printing “Naomi” look through your code, at the top.

console.log(cars[0]);

The cars array has 3 elements. I want to print the first element which is at position 0 (since they start numbering at 0. )

0,1,2.

That’s why I print “Saab” using cars[0].

So how do you print the first element of this array?

let rows = ["Naomi", "Quincy", "CamperChan"];

The first elament wil be “0”, Right?

That’s right. Now how would you print the first element of the rows array?