Learn Introductory JavaScript by Building a Pyramid Generator - Step 41

Tell us what’s happening:

Please help, I have been stuck on step 41 of the JS Intro Pyramid Generator for 5 days now. The for… of loop

(You should declare a row variable.
You should use const to declare your row variable.
Your for…of loop should declare your row variable.
Your row variable should be extracted from rows using the of keyword.
Your for…of loop body should be empty.
// tests completed
)

I have no idea what to do now and I’m starting to feel a bit stupid, please help a brother out.

Your code so far

const character = "#";
const count = 8;
const rows = [row];
const row = "";
for (let row of rows) {
}

let result = ""

// User Editable Region



// User Editable Region


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

Challenge Information:

Learn Introductory JavaScript by Building a Pyramid Generator - Step 41

You deleted code that is required in this step.

Please click reset and then add the new code without deleting the old code.

const character = “#”;
const count = 8;
const rows = ;

for (let i = 0; i < count; i = i + 1) {
rows.push(i);
}

let result = “”

console.log(result);

Hi, thank you for the response. So when I am at this point what should I do. Basically I do not know what to add into the for Loop as it keeps saying it’s wrong.

After resetting I then added “const row = rows”

const character = “#”;
const count = 8;
const rows = ;
const row = “rows”;
for (let i = 0; i < count; i = i + 1) {
rows.push(i);
}

let result = “”

for (let row of rows);

console.log(result);

This is killing me lol.

you were not asked to redeclare rows? rows is already declared.

1 Like

Alright, well the problem is that originally got this response : You should declare a row variable.
You should use const to declare your row variable.
Your for…of loop should declare your row variable.
Your row variable should be extracted from rows using the of keyword.
Your for…of loop body should be empty.

I have gone back to earlier sections now to see if perhaps I missed something because I truly do not understand what to do on this step.

yes, the hint is trying to help you write the for loop (not to redeclare the rows variable).
Notice that the rows variable is a plural form of the word row.
And the hint didn’t say “You should use const to declare your rows variable” (they said row not rows).

So looking only at the for loop you wrote. Does it use ‘const’ to declare a row (no s) variable?

are you able to see the example code in the step? it should match that.

for (const value of iterable) {

}
1 Like

Thank you so much for your help. Made it :grinning:

Mod edit: code removed.

1 Like

Great work! (I did remove the solution so that others can read this thread and work out the solution themselves)

1 Like

Understood. Again thank you, i was getting frustrated and almost quit, lol.

yes getting used to the fCC methods of checking code is an ongoing challenge for many (including me).

1 Like

I am so glad I made it through, I’m planning on taking Bcom IT next year so I am basically checking my readiness to see if I won’t fail dismally when the time comes, I have to say so far not so bad, though I was seriously starting to doubt myself :sweat_smile:

oh that’s very industrious of you!
Do you know what are some of the courses they teach?

Sorry for the late response, the courses are below:
Year 1
Semester 1

Introduction to Business Management

Fundamentals of Computer Programming

Analytical Techniques

Microeconomic Essentials

Semester 2

Introduction to Functional Areas of Management

Advanced Programming Concepts

Financial Reporting and Analysis

Macroeconomics Essentials

Year 2
Semester 1

Principles of Information Technology Management

Database Design and Management

Management Accounting

Advanced Business Statistics

Semester 2

Strategic Information Technology Management

Principles of Project Management

Principles of E-Commerce

Information Systems

Year 3

Semester 1

Information Technology Services Management

Principles of Soft Engineering

Auditing

Systems Analysis and Design

Semester 2

Information Technology Law and Ethics

Software Engineering Practice

Capstone Project

The fCC programming you are doing may help you think more logically so that you can do better in the first two programming courses you will take. However, if the programming language in your school is Python, you will have different syntax and ideas to get used to there. (Might be worth jumping on Reddit to ask current students there what languages the first two courses use).

Beyond that though, the year 2+ courses (like db design, system design etc) are not discussed by the fCC curriculum.

1 Like

Thank you for that advice, will definitely get more information on that.

1 Like

A post was split to a new topic: Add two numbers