# Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

**URL:** <https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [November 6, 2024, 7:18pm UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476 "2024-11-06T19:18:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis-code153](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dennis-code153/32/365256_2.png) [@Dennis-code153](https://forum.freecodecamp.org/u/Dennis-code153)\
**Post date:** [November 6, 2024, 7:18pm UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476/1 "2024-11-06T19:18:23Z")

</div>

### Tell us what’s happening:

> Hello. What is wrong with my code? Please help me.

```auto
 function padRow(rowIndex, totalRows) {
> const paddingLength = totalRows - rowIndex;
> const starsLength = rowIndex * 2 - 1;
> return ' '.repeat(paddingLength) + '*'.repeat(starsLength);
> }
> let rows = [];
> let continueLoop = true;
> let done = 1;
> const count = 7; 
> while (continueLoop) {
> rows.push(padRow(done, count));
> done++;
> if (done > count) {
> continueLoop = false;
> }
> }
> console.log(rows.join('\n')); 

```

### Your code so far

```javascript
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));
}*/

let continueLoop = false;
let done = 0;

while (continueLoop) {
  done++;

// User Editable Region

function padRow(rowIndex, totalRows) {
  const paddingLength = totalRows - rowIndex;
  const starsLength = rowIndex * 2 - 1;
  return ' '.repeat(paddingLength) + '*'.repeat(starsLength);
}
let rows = [];
let continueLoop = true;
let done = 1;
const count = 7; 
while (continueLoop) {
  rows.push(padRow(done, count));
  done++;
  if (done > count) {
    continueLoop = false;
  }
}
console.log(rows.join('\n')); 

// User Editable Region

  if (done === count) {
    continueLoop = false;
  } 
}

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 OPR/114.0.0.0`

### Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 90

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/step-90)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [November 6, 2024, 7:25pm UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476/2 "2024-11-06T19:25:53Z")

</div>

you need to add one line in this step, where all the other code comes from?

---

<div class="post-metadata">

**Author:** ![Dennis-code153](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dennis-code153/32/365256_2.png) [@Dennis-code153](https://forum.freecodecamp.org/u/Dennis-code153)\
**Post date:** [November 6, 2024, 7:29pm UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476/3 "2024-11-06T19:29:00Z")

</div>

When I took the code from line 11 and changed it, the result was:

```auto
while (continueLoop) {
  rows.push(padRow(done, count));
  done++;                       

  if (done === count) {
    continueLoop = false;         
  }
}

```

Then I continued changing it according to the comments below and to the right.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [November 6, 2024, 7:52pm UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476/4 "2024-11-06T19:52:32Z")

</div>

the loop is already there, look above and below the instructions

this is the starting code for this step

you need to add one line

```javascript
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));
}*/

let continueLoop = false;
let done = 0;

while (continueLoop) {
  done++;

// User Editable Region

// User Editable Region

  if (done === count) {
    continueLoop = false;
  } 
}

let result = ""

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

console.log(result);

```

---

<div class="post-metadata">

**Author:** ![Dennis-code153](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dennis-code153/32/365256_2.png) [@Dennis-code153](https://forum.freecodecamp.org/u/Dennis-code153)\
**Post date:** [November 6, 2024, 8:43pm UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476/5 "2024-11-06T20:43:25Z")

</div>

Thanks, you’ve really helped me manage the challenge.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [May 8, 2025, 8:44am UTC](https://forum.freecodecamp.org/t/learn-introductory-javascript-by-building-a-pyramid-generator-step-90/719476/6 "2025-05-08T08:44:24Z")

</div>

Closed on May 8, 2025, 8:44am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
