Learn Introductory JavaScript by Building a Pyramid Generator - Step 60

Tell us what’s happening:

Hello can anyone help me with this task?

Your code so far

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


// User Editable Region

function padRow(test) {
  const test = "Testing!";
  console.log("This works!")
  return test;
}
  console.log("This works!")



// 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 60

what did you need help with? (understanding something? finding a bug?)

I’m struggling with validating my code, as outlined above. I’ve followed the return instructions I’m struggling to link the code, actions.

The problem may be that your console.log (the bottom one) is outside the function scope (beyond the closing } of the function body).
Move it up so it comes right after the return but before the closing curly brace }

Can you show me an example to correct this?

If you try what I said that should be enough:

Let me know if I need to clarify a word or something else I said.

I tried it’s still not working I don’t know if I need to wrap anything.

const test = “Testing!”;
console.log(“This works!”)
console.log(“This works!”)
return test;Preformatted text

let’s take a step back to the beginning and follow the instructions carefully.

First click reset to get the original code back.
Then follow the first request given which was:

Below the return statement, log the string "This works!" to the console.

When you have done that, making sure that the new log statement is directly below the return statement and directly above the closing parenthesis } then you can move on to the next part of the instructions.

Done. What’s the parenthesis again?

function padRow(name) {
const test = “Testing”;
“This works”;
return test;
“This works”;
}

> Blockquote

This is the edited version,

function padRow(name) {
const test = “Testing”;
console.log(“This works!”)
return test;
“This works!”;
}Preformatted text

parenthesis are { and }

do you still need help or you’re all good now?

Edit: I should have said curly brace } (not parenthesis)

Yes I’m stuck on the same task.

okay have you tried my previous suggestion?
I suggested you click reset and then follow the first part of the instructions.

If you have tried it, can you post your code after trying this first part?
If you have a question about something I said above, please ask me.

This is as far as I’ve gone with my debugging I don’t know if I’m heading in the right direction here,

function padRow(test) {
const test = “Testing”;
console.log();
console.log(“This works!”);
}
return test;Preformatted text

when I click reset, the code looks like this for me:

function padRow(name) {
  const test = "Testing";
  
  return test;

}

Check that you can see the same thing when you click reset.

After that you should add the new console.log —after— the return statement and —above— the curly brace }

Please try again. (do not move any code around, just add your code in the empty line between return and } closing curly brace )

Done,

function padRow(name) {
const test = “Testing”;

return test;
console.log
}Preformatted text

can you finish this statement? (they said to log something, but this statement is not complete)

I’ve made the amendments,

function padRow(name) {
const test = “Testing”;

return test;
console.log(“This works!”)
}Preformatted text

1 Like

Great! Now you have the first part of the instructions completed. We can move on to the second part which was:

After doing that, you will see that the string "This works!" does not display in the console, and the console.log("This works!") line is greyed out.

Copy the console log and paste it above the return statement. Now, the string "This works!" should appear in the console.

So you should be able to check the console to see that the logged string did --not-- show up there. And the step explains why that is.

After you have confirmed this behaviour you can do the final part which is to copy the new line of code you made (make a copy , do not cut it, just copy it) and paste it above the return statement.