Learn Introductory JavaScript by Building a Pyramid generator Step 99

Tell us what’s happening:

Step 99
What if you made your pyramid upside-down, or inverted? Time to try it out!

Start by creating a new for loop. Declare your iterator i and assign it the value of count, then use the boolean false for your condition and iteration statements.

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

/*while (rows.length < count) {
  rows.push(padRow(rows.length + 1, count));
}*/


// User Editable Region


for (let i = count; false;) {  
}

// 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/126.0.0.0 Safari/537.36

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 99

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

2 Likes

for (iterator, condition, interation){}

Mod edit: code removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

hi there Axel, please use the Help button to open your own topic to get help for your question. It will create a template post for you and will include a link to the step and your code so we can respond directly to you without bothering other people here.

1 Like

regarding step number 99
When starting the for loop, the option that worked for me is the following
As I see, you are missing the condition that must also be false

Mod edit: code removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Hello and welcome to the forum @anjalisharma7978 !

I imagine you have resolved the problem here.

But if not, the code

is missing the iteration as we are instructed to do:

then use the boolean false for your condition and iteration statements.

Wishing you good progress on your coding journey. :slightly_smiling_face:

thanks. Your hint helped me in solving the problem.

1 Like

You are welcome! Happy to help another member of the community, and learner.

Wishing you more good progress on your coding journey! :slightly_smiling_face:

the best solution is shown below as the instructions are clear initialise the loop to count and use boolean false as both condition and iteration.

Mod edit: code removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.