Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

Tell us what’s happening:

hi guys who can help me with step 23 of java scrip
it asks to make a string variable cities with 3 elemet (london, new york, maumi)
and then asks to change the las element with Mexico citiy
i check one one but it didnt work !

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


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

you can’t define the same variable twice. Define the variable only once, then change the array using bracket notation.

you need to make New York and Mumbai two different strings, not only one

1 Like

can you please give an example?

Tell us what’s happening:

Hello Guys
who can help me with the step of 23 Java Script?

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)=["london","New York","Mexico City"];


// User Editable Region

console.log(rows);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

like London is its own string, you need to have New York be a string wrapped in quotes, and Mumbai also a string wrapped in quotes

here two examples from your own code:

1 Like

delete this line, and change the last eleement of the array using bracket notation to access only the third element

also London needs an upper case L

1 Like

Ive changed the Londens first letter to the upper Case L
but still didn’t make it

show your code please

1 Like

Ive wrote something like that :

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

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

you have two syntax issues:

the dot after the square bracket

this line as a whole, delete it

you did not try to reassign the 3 element of the array yet

1 Like

HI @fate1 !

You should do the following to pass the test

as mentioned, you need to delete this here

Then you need to review the previous step here

you see how you updated the last element of the rows array to 10 here?

rows[rows.length - 1] = 10;

you need to do something similar for the cities array and the string "Mexico City"

it looks like you were trying to do that here

but that dot shouldn’t be there and you are missing the assignment of the string "Mexico City"

look back at the previous step so you can see correct syntax

once you fix that, then the test should pass

hope that helps

1 Like

i just wanna say tnx
i finally solved step 23
your cues was helpful

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