Tell us what’s happening:
Following the example provided but can’t find the right body command the program is looking for.
Your code so far
const character = "#";
const count = 8;
const rows = [];
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
rows.push(padRow(i, count));
}*/
// User Editable Region
if (true) {
return "Condition is true";
}
// User Editable Region
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/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Challenge Information:
Learn Introductory JavaScript by Building a Pyramid Generator - Step 78
In the body, print the string "Condition is true"
.
A return
statement doesn’t print anything
if (true) {
“Condition is true”
}
Is the body not the part between the brackets?
The body is the part between the brackets. You aren’t printing anything to the console in the body
printing to the console always happened outside the body, after the bracket closed. I went to the javascript school link and it shows what I have
do I True in the body? Would a console.log statement go in the body too?
if (true) {
true = “Condition is true”;
}
I don’t know what this means’ but I don’t think it is correct.
I already saw the example. Do you remember how to print something out to the console?
yes console.log() however it always looked like this
if (true) {
result = “Condition is true”;
}
console.log(true);
No, it hasn’t always looked like that?
I took a break and re-read through then did something we were not taught in any of the lessons so far and it worked. I assume that’s what you were leading me to.
You should have been shown how to log something to the console in previous Steps?