Learn Introductory JavaScript by Building a Pyramid Generator - Step 69

Tell us what’s happening:

hi guys
ill be grateful if any one of you give me a hint about step 69
i wrote down this line but it was not a solution!!!
console.log(character);
return “rowCount " + character.repeat(” ") + “rowNumber”;

Your code so far

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


// User Editable Region

function padRow(rowNumber, rowCount) {
  console.log(character);
  return "rowCount " + character.repeat(" ") + "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 (Windows NT 10.0; Win64; x64) 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 69

1 Like

Your blank space should be repeated before and after the character repeating, according to the instructions:

" ".repeat... this is guidance

You don’t need the console.log(character); at all.

Reread the instructions.

2 Likes

is that mean that i should omit character and instead ad an empty space of string " " before my repeat??
you mean this : " “.repeat(rowNumber)+” " !!!
if you mean that it is still not correct
should i also use dot in empty space?
where should i put rowCount and rowNumber ??!!
if it should be placed in empty spaces between and and after character.repeat(rowNumber) i placed it once but it was still wrong!!!
more clear guidance please !

1 Like

As you can see you didn’t use the same quote characters. It should be like this:
" ".repeat()
A blank space should be repeated ‘rowCount - rowNumber’. You only have the rowNumber as the number of repeated blank spaces. The same statement should be on the right side of the character.repeat(rowNumber) too. So, instead of only having quotes as in the given code in this challenge you should have “”.repeat… (as mentioned above).

1 Like

by blank space you mean () or “” ??
by the way when i wrote down the quotes on the test they were the same but when i copy pasted them here the shape of the quote just changed?! dont know why!!!

1 Like

Hi there!
Blank space is the to double quote marks " " , that contains a space between it.
You need to reset your challenge step and add .repeat() method on both blank space strings, and add rowCount - rowNumber times as an argument.

2 Likes

Always post your new code here. That is best for us to get an insight into your approach to the final solution of the challenge.

2 Likes

hi mr hasan.
thanks for guidance
istill have bunch of problem
one what do you exactly mean by resting my challange ! is that an idiom ?
you mean something like that?
" " .repeat() + character.repeat(rowNumber) + " ".repeat();
and what it mean rowCount - rowNumber times!! it means i should add this two item (`rowCount - rowNumber) in my blank like this
"rowCount - " .repeat() + character.repeat(rowNumber) + " rowNumber ".repeat();
please help me with more detail tnx

1 Like

ok my new codes that that was wrong up untill now is:

  1. return " “+character.repeat(rowNumber)+” ";

  2. return "rowCount - “+character.repeat(rowNumber)+” rowNumber ";

and as our friend hasan said to add .repeat() in both blank side i wrote this :

  1. return " rowCount - " .repeat() + character.repeat(rowNumber) + "rowNumber ".repeat();

4.return return "rowCount - " .repeat(character) + character.repeat(rowNumber) + " rowNumber ".repeat(character);

but still i dont reach into the correct answer!!!

1 Like

i also try that
return " rowCount".repeat(1)+“rowNumber”.repeat(1);
and this :
return “rowCount” .repeat(1) + character +"rowNumber ".repeat(1);
and this :
return “rowCount” .repeat(1) + character.repeat() +"rowNumber ".repeat(1);
and also this:
return “rowCount” .repeat(1) + character.repeat(rowNumber) +"rowNumber ".repeat(1);
but non of them was the answer
help me guys!!!

1 Like

do not change the content of the quotes, the string should contain a space, do not change that

you use repeat() on that string, repeat() gets a number as argument, that number should be rowCount - rowNumber, it’s calculated depending on the values of rowCount and rowNumber. When it says rowCount - rowNumber times, you just put exactly that as number of times the string should be repeated

2 Likes

Example

str.repeat(argument)

You need to add rowCount - rowNumber as the repeat method argument on both " " blank space strings.

2 Likes

you mean quotes should be empty like this " "

1 Like

not empty, but with a space inside

"" #empty string
" " #string with a space
2 Likes

hello hasan
like this you mean?
" ".repeat(rowCount-rowNumber);

1 Like

Yes, like that on both side.

2 Likes

But don’t add semicolon after first one

2 Likes

thank you dear Hasan
that was the answer
:raised_hands:

2 Likes

tnx dear ilenia
finally problem solved.

1 Like