FAQ: Objects - Looping Through Objects

can you suggest any websites where I can learn to build interactive websites using javaScript. Unfortunately I cannot learn from here because of financial issues. When I start the course “Building Interactive JavaScript Websites” I didn’t know that it was a paid course, now I completed 3 pages of first lecture then got stuck. so kindly suggest me some websites

1 Like

TBH, I’m a bit out of touch given retirement and age (no longer any career aspirations) and I’m pretty much out of the field now, except to address beginner’s questions on occasion. In years past I relied quite heavily on SitePoint, and in present day terms one would think they are still a going concern and a reliable source of information and print material (books, ebooks, forum, etc.) Since letting my Premium account expire (that I had paid for for many years) I’ve not kept up with the site. It is worth checking out. Premium was about 100$ a year and worth every penny.

Another going concern is freecodecamp, where you might even bump into some of your fellow members from here. They have a lot of material exposed for free. Again, being rather sedentary these past couple of years I’ve not visited the site but I still get their emails, so they are busy at progressively adding new material. Whether or not they have a pay wall around any material I cannot say.

If you are a student then CC might offer a sizable discount on their Pro subscription. Worth checking out. They really do have a tonne of material behind their pay wall so you are guaranteed to find plenty of value if you take advantage of that access. It’s an investment in yourself, remember.

At any length, the web is chalk-full of free material. What you could do is spend an afternoon in your local or school library and create an outline for yourself of what you wish to learn and in what order. Then you can tailor your searching and studying to your schedule.


Thanks for everything. I appreciate your response.


For the record, the exercise 1 erroneously demands that the new variable be exactly named crewMember even though it would make more sense to call it crewMemberAndName - maybe I’m wrong?
Also it throws an error for the same syntax in the last line in the picture that it uses in the sample image. I have a feeling the last chapters were not done by the same people as the first ones.

1 Like

For the error in last line - see the last line you didn’t put " ; " (semicolon) after closing curly bracket " } "

it is because of the requirement of this chapter’s exercise. It is important to write the exact variable name otherwise it would throw an error but this error is not from JS instead it is from the lecturer or whomever made this exercise. however, you can use any variable name (a valid name) while practicing. I hope you understand what I said.

1 Like

It is not an error in the exercise.

In your screenshot, you have chosen crewMemberAndRole as the loop variable. But in the body of your loop, you are trying to access a non-existent variable named crewMember.

// You wrote:
console.log(`${crewMemberAndRole}: ${spaceship.crew[crewMember].name}`);

If you wish to use crewMemberAndRole as the loop variable, then the statement should be:

console.log(`${crewMemberAndRole}: ${spaceship.crew[crewMemberAndRole].name}`);

The instructions don’t specify what the loop variable should be named, so you have leeway in picking whatever name you consider suitable. However, the instructions are particular about the output (the punctuation, spelling etc.) that the loop should log to the console.

Your solution is not being rejected because you chose a different name for the loop variable. It is because you are trying to reference a non-existent variable in the loop’s body.

1 Like

@mhs_007 yes I do, thank you for replying. I just believe earlier exercises were more forgiving with this, but not sure.

@mtrtmk, thanks for catching that, you are right!

1 Like