Back to Freecodecamp

Step 29

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

latest1.2 KB
Original Source

--description--

Were you expecting to see 4 in the console? .push() returns the new length of the array, after adding the value you give it.

It is important to be aware of what values a method returns. Take some time to experiment with .push() and .pop(). When you are ready, remove all of your .push() and .pop() calls, and your console.log statements.

--hints--

You should not have a .push() call.

js
assert.notMatch(__helpers.removeJSComments(code), /\.push\(/);

You should not have a .pop() call.

js
assert.notMatch(__helpers.removeJSComments(code), /\.pop\(/);

You should not have any log statements.

js
assert.notMatch(__helpers.removeJSComments(code), /console\.log/);

You should not have a popped variable.

js
assert.notMatch(__helpers.removeJSComments(code), /popped/);

You should not have a pushed variable.

js
assert.notMatch(__helpers.removeJSComments(code), /pushed/);

--seed--

--seed-contents--

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