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 Loops, Arrays and Objects Tracking Multiple Items with Arrays Iterating through an Array

My Creation
My Creation
1,289 Points

Can't quite grasp this one for some reason. Can someone help me out here?

I need to iterate these variables in order from 100 to 10 but I found the code to be a bit confusing because I haven't worked in JS in a while and I don't quite understand the video explaining it. Can someone help me out here?

script.js
var temperatures = [100,90,99,80,70,65,30,10];

for (m = 0; m < temperatures.length; m += 1) {
  console.log(m);
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey there,

You're really close.

Instead of logging out just the value of the iteration variable (m), you need to log out the value in the array being iterated through. You use [] to access the index of the array, so it would be something like this: console.log(nameOfArray[index]).

I hope this helps! :)

Keep Coding! :dizzy: