Learn Introductory JavaScript by Building a Pyramid Generator - Step 24

Tell us what’s happening:

unable to use array[array.length -1] to access last element in an array and also to console.log the array assigned variable

Your code so far

let character = 'Hello';
let count = 8;
let rows = ["Naomi", "Quincy", "CamperChan"];

// User Editable Region

console.log(rows);

let cities =["London", "New York", "Mumbai" ];
console.log(cities);
cities[2]= "Mexico city";
cities[cities.length - 1],
console.log(cities);

// User Editable Region


Your browser information:

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 24

Hi there and welcome to our community!

You can use cities[2] to access the last element in this array, but it should be ‘Mexico City’ (with a capital C):

Fix the spelling and remove cities[cities.length - 1], as this is redundant.