Back to Freecodecamp

Step 21

curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f07d231941bc11719f664.md

latest1.5 KB
Original Source

--description--

Arrays are special in that they are considered <dfn>mutable</dfn>. 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:

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

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

--hints--

You should use bracket notation on the rows array again.

js
assert.lengthOf(__helpers.removeJSComments(code).match(/rows\[/g), 2)

You should access the third element of the rows array.

js
assert.match(__helpers.removeJSComments(code), /rows\[\s*2\s*\]/);

You should use the assignment operator on the third element of the rows array.

js
assert.match(__helpers.removeJSComments(code), /rows\[\s*2\s*\]\s*=/);

You should assign the value 10 to the third element of your rows array.

js
assert.equal(rows[2], 10);

You should have a second console.log statement in your code.

js
assert.lengthOf(__helpers.removeJSComments(code).match(/console\.log/g), 2);

You should log the rows array.

js
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*rows\s*\);?/);

--seed--

--seed-contents--

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

--fcc-editable-region--