mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-22 11:36:11 -05:00
1.5 KiB
1.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 660f415b76859a2736771607 | Step 78 | 1 | step-78 |
--description--
Your pyramid has disappeared again. That's okay - that is to be expected.
Before you create your new loop, you need to learn about if statements. An if statement allows you to run a block of code only when a condition is met. They use the following syntax:
if (condition) {
logic
}
Create an if statement with the boolean true as the condition. In the body, print the string "Condition is true".
--hints--
You should create an if statement.
assert.match(__helpers.removeJSComments(code), /if/);
Your if statement should have true as the condition.
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*true\s*\)/);
Your if body should log "Condition is true".
assert.match(__helpers.removeJSComments(code), /if\s*\(\s*true\s*\)\s*\{\s*console\.log\(\s*("|')Condition is true\1\s*\);?/);
--seed--
--seed-contents--
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));
}*/
--fcc-editable-region--
--fcc-editable-region--
let result = ""
for (const row of rows) {
result = result + "\n" + row;
}
console.log(result);