Learn Introductory JavaScript by Building a Pyramid Generator - Step 28

Tell us what’s happening:

Step 28
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.

Your code so far

let character = 'Hello';
let count = 8;
let rows = ["Naomi", "Quincy", "CamperChan"];

// User Editable Region

rows.push("freeCodeCamp");
let pushed = rows.push("freeCodeCamp");
let pushed = rows.push('freeCodeCamp');
console.log(pushed);

// User Editable Region

let popped = rows.pop();
console.log(popped);
console.log(rows);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 28

You have some duplicate lines here.

Edit the existing push line, don’t add a new one.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.