Back to Freecodecamp

Step 28

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

latest1.1 KB
Original Source

--description--

You should have seen "freeCodeCamp" printed to the console. This is because .pop() returns the value that was removed from the array - and you pushed "freeCodeCamp" to the end of the array earlier.

But what does .push() return? Assign your existing rows.push() to a new pushed variable, and log it.

--hints--

You should declare a pushed variable.

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

You should use let to declare your pushed variable.

js
assert.match(__helpers.removeJSComments(code), /let\s+pushed/);

You should assign rows.push("freeCodeCamp") to your pushed variable.

js
assert.equal(pushed, 4);

You should log your pushed variable.

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

--seed--

--seed-contents--

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

--fcc-editable-region--
let popped = rows.pop();
console.log(popped);
console.log(rows);