const character = “#”;
const count = 8;
const rows = ;
function padRow(rowNumber, rowCount) {
let result=“”;
for (let i = 0; i < rowCount; i = i + 1) {
result+=character.repeat(rowNumber)+“\n”;
}
return result;
}
for (let i = 0; i < count; i = i + 1) {
rows.push(character.repeat(i + 1))
}
let result = “”
for (const row of rows) {
result+=row;
}
console.log(padRow(character,count));
It says return the .repeat() function I tried myself, asked friends help but nothing worked even ask an AI to help me solve it
1 Like
Welcome to the forum @fatlumhasaj4
You appear to have declared the result variable and added a for loop, which the instructions did not ask you to do.
The .repeat method is a quick way to repeat something. So you don’t need the loop, or to declare a variable to return.
Happy coding
2 Likes
Thanks alot for the solution, I have problems to apply it could u send me the solution in code
const character = “#”;
const count = 8;
const rows = ;
function padRow(rowNumber, rowCount) {
return character.repeat(rowNumber)+"\n";
}
for (let i = 0; i < count; i = i + 1) {
rows.push(character.repeat(i + 1))
}
let result = “”
for (const row of rows) {
result+=row;
}
console.log(padRow(character,count)); this is how I understood the solution you gave but I am doing something wrong according to instructions
solved it it was the “\n” thanks alot for your help may God reward you
1 Like
system
Closed
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.