Learn Introductory JavaScript by Building a Pyramid Generator - Step 24

Tell us what’s happening:

I keep getting this error. I have tried to close the browser, and just refresh it/ reset the prompt. What am I doing wrong?

// running tests
2. You should assign an array of the strings “London”, “New York”, and “Mumbai” to the cities variable.
4. You should update the last element of the cities array to the string “Mexico City”. Remember that you can access the last element of an array using array[array.length - 1].
// tests completed

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);
cities[cities.length - 1]="Mexico City";
console.log(cities);

// User Editable Region

console.log(rows);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 24

Look at the console, you should be getting an error message.

Read it and it will indicate where you should look for the problem.

Then check out how you assign the rows array.

that’s the thing though, the errors I am getting, it seems like I am doing it right. However it won’t clear. I went back to previous steps to see what I did wrong and I can’t seem to find anything that I am missing.

Got it figured out finally. only took a few hours. wow!!!

1 Like

You should always share the error in the forum so we can talk about it.

This is the error you were getting:

SyntaxError: unknown: Missing semicolon. (4:10)

  2 | let count = 8;
  3 | let rows = ["Naomi", "Quincy", "CamperChan"];
> 4 | let cities["London", "New York", "Mumbai"];
    |           ^
  5 | console.log(cities);
  6 | cities[cities.length - 1]="Mexico City";
  7 | console.log(cities);

You can see how the little > and ^ arrows were indicating the spot where there is a syntax error. It says “missing semicolon” which is a bit mis-leading isn’t it?

If you look up just 1 line of code you can see where you assign the rows array and how it’s different in that spot:

  3 | let rows = ["Naomi", "Quincy", "CamperChan"];
> 4 | let cities["London", "New York", "Mumbai"];
    |           ^

Hopefully this helps interpret future errors!

1 Like