Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Arrays Loop Through Arrays Loop Through an Array

im about to give up smh

script.js
const temperatures = [100, 90, 99, 80, 70, 65, 30, 10];
for ( let i = 100; i > temperatures.length; i++ ) {
  console.log(temperatures[i]);
}

totally worked!! Thanks

1 Answer

Hi Ulyssa!

I think the challenge wording threw you off a bit.

This passes the task:

const temperatures = [100, 90, 99, 80, 70, 65, 30, 10];

for ( let i = 0; i < temperatures.length; i++ ) {
  console.log(temperatures[i]);
}

100 is the value at the first ordinal position in the array (temperatures[0]) and 10 is in the last/7th ordinal position in the array (temperatures[7]).

So you want i to go from 0 to 7 in the loop iterations (temperatures.length is 8 in this case, which is why you want to use <.

I hope that helps.

Stay safe and happy coding!

My bad...

I just saw the follow-up comments right after I answered!?! LOL