Learn Introductory JavaScript by Building a Pyramid Generator - Step 19

Tell us what’s happening:

I can't figure out what I'm doing wrong. Trying to access the last element of the array using .length
Any help is greatly appreciated.

console.log([rows.length -1])= 10’

Your code so far

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

// User Editable Region

console.log([rows.length-1])= 10;

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 19

you can’t assign to a function call

the starting code is

rows[2] = 10

you need to change that to access instead of the element at index 2, the element at index length of rows minus 1

Hey :),
It took me some effort to correctly understand the assignment but perhaps it will enlighten by another perspective.
you’re asked to try to access the same element by another means which is the rows.length -1. ← try to see how to insert that into the first rows[2].

rows[rows.length -1] =10

1 Like
 "This is not what I expected it to look like.  But it works!  Thanks for the help."

rows[rows.length - 1] = 10

I went ahead and created an issue to update the description to show a different code example so beginners will better understand what the syntax should look like

change this
rows[2] = 10

with this
rows[rows.length -1];

and, if it’s still doesn’t work you may have to delete this console.log(rows[0]);