Files

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
660f280dda5040f707c76b4a Step 45 1 step-45

--description--

Now you have a series of # characters, but the pyramid shape is still missing. Fortunately, the i variable represents the current "row" number in your loop, enabling you to use it for crafting a pyramid-like structure.

To achieve this, you will use the .repeat() method available to strings. This method accepts a number as an argument, specifying the number of times to repeat the target string. For example, using .repeat() to generate the string "Code! Code! Code!":

const activity = "Code! ";
activity.repeat(3);

Use the .repeat() method on your character, and give it i for the number.

--hints--

You should use the .repeat() method.

assert.match(__helpers.removeJSComments(code), /\.repeat\(/);

You should use the .repeat() method on your character variable.

assert.match(__helpers.removeJSComments(code), /character\.repeat\(/);

You should pass i to your .repeat() method.

assert.match(__helpers.removeJSComments(code), /character\.repeat\(\s*i\s*\)/)

--seed--

--seed-contents--

const character = "#";
const count = 8;
const rows = [];

--fcc-editable-region--
for (let i = 0; i < count; i = i + 1) {
  rows.push(character);
}
--fcc-editable-region--

let result = ""

for (const row of rows) {
  result = result + "\n" + row;
}

console.log(result);