Learn Introductory JavaScript by Building a Pyramid Generator - Step 18

Tell us what’s happening:

Please can someone explain to me what I am doing wrong? Question Below:

Arrays are special in that they are considered mutable. This means you can change the value at an index directly.

For example, this code would assign the number 25 to the second element in the array:

let array = [1, 2, 3];
array[1] = 25;
Update the third element of your rows array to be the number 10. Then print the rows array to your console.

My Answer:

rows[2] = 10;
console.log(rows[2]);

I cannot pass step 18.

Your code so far

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

// User Editable Region

rows[2] = 10;
console.log(rows[2]);

// 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/124.0.0.0 Safari/537.36 Edg/124.0.0.0

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 18

Then print the rows array to your console.

Print the entire array, not just the updated element

rows[2] = 10;

console.log(rows[0, 1, 2]);

Like this?

What if you didn’t know how many elements the array has?

Ah I understand and now, worked out the solution:

— solution removed—

1 Like

Nice work! Please don’t post solution code to the forum though