Learn Introductory JavaScript by Building a Pyramid Generator - Step 28

Tell us what’s happening:

Hello everyone,

I’m currently working on Exercise 28 of the JavaScript course, and I’m encountering an issue with the instructions. The exercise asks me to assign the return value of rows.push(“freeCodeCamp”) to a variable pushed and log it to the console.

Here’s my code:
let pushed = rows.push(“freeCodeCamp”);
console.log(pushed);

This works as expected and logs the new length of the array (which is 4 in my case). However, I keep getting the feedback that my solution is incorrect?

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");
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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 28

Hi. Once you have assigned your existing rows.push() to the pushed variable you can delete the original line and just have the variable and the console log.

Hi,
Thanks for the reply. However I’m having trouble understanding what you mean? Can you possibly type an example of the code?

you are pushing twice, nowhere you are asked to do this, the tests don’t recognise the value of pushed variable for that

Okay realized my mistake. Thanks.

It’s :
solution removed by moderator

I have removed the solution

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.

1 Like