Learn Introductory JavaScript by Building a Pyramid Generator - Step 40

Tell us what’s happening:

I have been stuck on this challenge for the past few days pls help

Your code so far

const character = "#";
const count = 8;
const rows = [];
for (let i = 0; i < count; i = i + 1) {

// User Editable Region

  rows.push(i);
function createPyramid(rows) {
    let result = "";

    for (let i = 1; i <= rows; i++) {
        let row = "";
        for (let j = 1; j <= i; j++) {
            row += j + " ";
        }
        result += row.trim() + "\n";
    }

    console.log(result);
}

createPyramid(5);

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 40

hi there.
I think you’ve changed a lot of code which was not required by this step.
My suggestion is to click the reset button to restore the original code and then focus on modifying the line in the editor that looks like this:
result = result + row;

All you have to do is follow the instruction to “concatenate a newline” in between the result and the row variables.

1 Like

reset the step, then concatenate only a string with the new line character

i have reset it but how do i contenate a newline

you learned about the concatenation operator earlier
It is the + symbol

And if you re-read the step, they tell you how to add a newline character (an example is presented so please take another look)

A post was split to a new topic: Forum questions comment