Back to Freecodecamp

Step 27

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

latest1.3 KB
Original Source

--description--

Another method essential for this project is the .pop() method. It removes the last element from an array and <dfn>returns</dfn> that element.

When a method returns a value, you can think of it as giving the value back to you, making it available for use in other parts of your code.

Create a new variable called popped and assign it the result of rows.pop(). Then, log popped to the console.

--hints--

You should declare a variable called popped.

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

You should use let to declare your variable called popped.

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

You should call the .pop() method.

js
assert.match(__helpers.removeJSComments(code), /\.pop\(\s*\)/);

You should call the .pop() method on your rows array.

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

You should log your popped variable.

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

--seed--

--seed-contents--

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

console.log(rows);
--fcc-editable-region--