Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

Tell us what’s happening:

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.

My resolution was:

rows.push(“freeCodeCamp”);
let pushed = rows.push(“freeCodeCamp”);

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");

// 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/116.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 23

use push once, not twice

The solution is adding the new pushed variable to the existing
rows.push(“freeCodeCamp”); line, rather than adding an additional line with the new pushed variable. Then make sure to log it after.

Code removed: mod edit
Happy coding!

1 Like

I am stuck here. Could you show me the code?
Here is my code:

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

You have the correct code, but you’re adding it as an additional line rather than editing the line that was already there.

rows.push(“freeCodeCamp”); is what you start with. Integrate the new pushed variable into that line instead of writing a new line, and you should be good.

Good luck and happy coding!

1 Like

hei @mesarojgiri please open your own post to ask for help

solution removed by moderator

please do not provide full solutions

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Mod edit: code removed

Hi ,
Not sure what the requirement refers to…anyone solved this?

Welcome to the FCC forum. Create your own topic to the challenge step, using help button. That’s appears after attempting check your code button more than three times.

:rofl::rofl::rofl::rofl:, i could not belive it. It works, :rofl::rofl::rofl:, how simple is that, :rofl::rofl:, thank you LinZ, i came here and search for answers and i found the answer. Happy Coding :rofl::rofl:

key word to look at this answer is, new variable.

I honestly feel like they purposely try to trick us, because it literally says " Assign your existing rows.push() to a * new* pushed variable, and log it." so I was putting this on a new line as well. I have to keep coming to these forums because its hard to wrap my head around what they are actually asking me to do.

2 Likes