my console is rejecting my code and its correct even according to the co-pilot
the code is result = result + “\n” + row; is this correct or its wrong?
Your code so far
const character = "#";
const count = 8;
const rows = [];
for (let i = 0; i < count; i = i + 1) {
rows.push(i);
}
let result = ""
// User Editable Region
for (const row of rows) {
result = result + "\n" + row;
}
// User Editable Region
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/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 43
The example is given just to teach us how to use \n to create a new line. In the example, you have line one, then \n which moves to the new line and then your line two.
It looks the same, but there’s a slight difference. When you put the \n before row, it creates an empty line and then proceeds with row, resulting in:
0
1
2
3
4
5
6
7
You can see the empty line in the console. But putting \n after row, adds row, in this case 0, first and then adds a new line after it.
I hope this helps!