Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

Tell us what’s happening:

Hi anyone can help me ? im get stucked how do i gonna string the mexico city and giving the array

Your code so far

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

// User Editable Region

let cities = [ "London", "New York", "Mumbai" ];
console.log(cities);
let cities = [ "London", "New York", 'Mexico City' ];
console.log(cities);



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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

don’t reassing the value of the variable, ise the methods you learned to change the third element in the array

You have to update the cities array by using its index.

let arr = ["element1", "element2", "element3"]

In the above example, the index (position) of “element1” is 0. Index starts from 0 in javascript. So the index of last element in the array arr will be 2.

To update any element in the array, we use square brackets.

arr[1] = "hey";
// Now the arr is ["element1", "hey", "element3"]

And don’t use any let or const keyword to update the array using square bracket notation.

In your case, you have to update the last element, so the index in your array will be 2. Now I think you can solve it.

There is no need to reassign the variable that you have already declared. The console will show you how to get the correct answer even if you don’t get it on the first go.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.