Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

Hi

I am having trouble with question 69 in the Javascript Algorithms and data structures.

Can someone please help with this?
Thanks in advance

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  return " " + character.repeat(rowNumber) + " ";
}
character.repeat(rowCount-rowNumber);

// User Editable Region


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

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/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Hi there!

Remove the second line of `character.repeat(rowCount - rowNumber);

You need to update your blank space strings " " to be repeated rowCount - rowNumber times.
Edit: see the example below:

string.repeat(times)

Repeat your both space strings rowCount - rowNumber times.
@iskren500

1 Like

I just removed character.repeat(rowCount- rowNumbers);

and I have this:
function padRow(rowNumber, rowCount) {
return " " + character.repeat(rowNumber) + " ";
}

what do I need to add, I don’t get it

I have updated my previous post, check it out.

I just added
" ".repeat(5);

still doesn’t work

Who asked you to add 5 to repeat method.? You need to add rowCount - rowNumber within the repeat method.

I just put it randomly, should I leave it blank?

You need to follow the instructions strictly. Don’t try rendom things when you working on the curriculum challenges. You need to add rowCount - rowNumber within repeat method for both blank strings.

this is what I put:
function padRow(rowNumber, rowCount) {
return “rowCount - rowNumber” + character.repeat(rowNumber) + “rowCount - rowNumber”;
}

" ".repeat(rowCount-rowNumber);

Your last line of code above is correct. But you need to do it exactly for existing blank strings you have above that last line within the function body. Reset the challenge step and try again.

I don’t get it dude, sorry

  return " " + character.repeat(rowNumber) + " ";

Above is the starting code for that challenge step. You have two blank strings " " within that code. Now you need to add .repeat() with rowCount - rowNumber times to that both blank space strings.

What do you not get? Try to ask a more specific question or we don’t know what to explain

Pkdvalis I need to move passed question 69 in the javascript algorithms and data structures, just go the question and there are instructions which I dont get

All of this is already obvious.

What is it about the instructions that you don’t understand? Be specific and we can help.

I dont get the entire thing

you need a number of spaces in the string that is determined programmatically, repeat helps with that as it repeats the string the given number of times.
So, " ".repeat(5) means:

"     "

instead of 5, you need to use the operation you are asked to use, that will result to a different value based on various things
You have written the expression to repeat the space, now you need to put it inside the return statement

I answered it, thanks

man i don’t get it, could you maybe guide me on how did you get to the answer?

hey @Program_Parker

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.