my problem is that idk how to repeat " " rowCount-rowNumber times by using .repeat()
Your code so far
const character = "#";
const count = 8;
const rows = [];
// User Editable Region
function padRow(rowNumber, rowCount) {
" ".repeat(rowCount - rowNumber);
return " " + 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; rv:128.0) Gecko/20100101 Firefox/128.0
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 69
What do you think it is returning? In other words, what sort of modifications do you think you are actually applying on the characters after calling the repeat methods in those different parts of the function?
And whatever the result, try to think also why you are getting that result.
You have to work that out yourself based on the hints given. If you need more help, you can post the updated code in your reply and ask a follow up question.
why can’t you just give the answer so i can understand later why, i don’t think i can get it . Just get back from a month vacation and i barely even remember what was happening.
The end goal is to return spaces, repeated a certain number of times, before and after the character repeated a certain number of times.
Update your blank space strings to be repeated rowCount - rowNumber times.
“update your blank space strings” means you should make a change to the blank space strings in this line:
return " " + character.repeat(rowNumber) + " ";
If you add it before the return then it won’t be returned. The line you added isn’t stored in a variable or returned so it just does nothing, it has no effect on the blank spaces that are in the return line.
if you’d like to, join the fCC discord server and discuss the code there one-on-one. It may help you move forward a bit faster since you’re struggling to understand the different responses you’ve received so far.
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.