JavaScript JavaScript Arrays Loop Through Arrays Loop Through an Array

Ulyssa Sneed
Ulyssa Sneed
6,025 Points

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]);
}
Ulyssa Sneed
Ulyssa Sneed
6,025 Points

totally worked!! Thanks

1 Answer

Peter Vann
MOD
Peter Vann
Treehouse Moderator 31,439 Points

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!

Peter Vann
Peter Vann
Treehouse Moderator 31,439 Points

My bad...

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