Learn Introductory JavaScript by Building a Pyramid Generator Step 58

Hi there,
I’m stuck on this one. Here’s my code:

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

function padRow(name) {
  const test = "Testing";
  return character + name;
}
console.log(test);
const call = padRow("CamperChan");
console.log(call);


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

and this is the output:

// running tests
Your function should declare a test variable.
You should initialise test with the value "Testing". Don't forget the semicolon.
Your test variable should come before your return keyword.
// tests completed
// console output
ReferenceError: test is not defined

What am I doing wrong?

Regards,
Devin M

Hello and Welcome to the forum!

I suggest resetting the code to the original and to remove any failed code.

Then, enter const variable where you have it.
Right below it enter the console.log() with the test call.

This may work for you.

Happy coding!

I think that worked. I ended up removing console.log(test); from the code and the tests passed. Thanks for your help!

1 Like