Learn Introductory JavaScript by Building a Pyramid Generator - Step 57

Tell us what’s happening:

It keeps saying my code doesn’t pass and the instructions it’s outputting in the console are:
// running tests
Your function should declare a test variable.
You should initialise test with the value “Testing”. Don’t forget the semi-colon.
Your test variable should come before your return keyword.
// tests completed
// console output
ReferenceError: test is not defined

I’ve tried changing character to test, but this outputs the same. Where am I going wrong?

Your code so far

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


// User Editable Region

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


// User Editable Region

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 57

the problem is this line. You cannot log test outside the function because it doesn’t exist there.

1 Like