Learn Introductory JavaScript by Building a Pyramid Generator - Step 47

Tell us what’s happening:

in step 47 i am writing below code but still throwing error that mention padRow function.

const character = “#”;
const count = 8;
const rows = ;

// User Editable Region

function name(padRow) {
}

// User Editable Region

for (let i = 0; i < count; i = i + 1) {
rows.push(character.repeat(i + 1))
}

let result = “”

for (const row of rows) {
result = result + “\n” + row;
}

console.log(result);

Your code so far


// User Editable Region

const character = "#";
const count = 8;
const rows = [];


// User Editable Region

function name(padRow) {
}

// User Editable Region



for (let i = 0; i < count; i = i + 1) {
  rows.push(character.repeat(i + 1))
}

let result = ""

for (const row of rows) {
  result = result + "\n" + row;
}

console.log(result);

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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 47

your function should be named padRow, not name, and you should not add any parameters to it

2 Likes

I have not added any parameter but still getting below error. please suggest the correct code.

You have written a function named name with a parameter padRow

You can refer this lecture to review how functions are made: https://www.freecodecamp.org/learn/full-stack-developer/lecture-working-with-functions/what-is-the-purpose-of-functions-and-how-do-they-work