Learn Introductory JavaScript by Building a Pyramid Generator - Step 21

Tell us what’s happening:

Hi,
I can’t seem to figure out what i’m missing, or what went wrong with this code.

Your code so far

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

// User Editable Region


let rows = ["Naomi", "Quincy", "CamperChan"];
rows[2] = 10;
console.log(rows);


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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 21

Update the third element of your rows array to be the number 10. Then print the rows array to your console.

You did more than the instructions asked you to do. If you look at the console, the error tells you which line the interpreter does not like:

SyntaxError: unknown: Identifier 'rows' has already been declared. (5:4)

  3 | let rows = ["Naomi", "Quincy", "CamperChan"];
  4 | console.log(rows[0]);
> 5 | let rows = ["Naomi", "Quincy", "CamperChan"];
    |     ^
  6 | rows[2] = 10;
  7 | console.log(rows);

Can i have the full correct code? I have been brainstorming for a week now :slight_smile:

No, I cannot give the solution to you.

Did you look at the error in the console like I suggested? Which line is the interpreter erroring on?

i don’t know :sob: i have been looking for a week now, i just can’t seem to find the error

Please read this. What line of code is being indicated (by two different arrows) as the ‘bad’ line?

is it the 5th line? let rows = [“Naomi”, “Quincy”, “CamperChan”];

Yes. Did the part of the instructions I quoted ask you to write that line?

no but my answer was based on the example code provided in the task

let array = [1, 2, 3];
array[1] = 25;
console.log(array); // prints [1, 25, 3]

Anyways, thank you so much :slight_smile:

You have to do what the instructions ask instead of only copying the example. Common gotcha

1 Like