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 trialUlyssa Sneed
8,894 Pointsim about to give up smh
const temperatures = [100, 90, 99, 80, 70, 65, 30, 10];
for ( let i = 100; i > temperatures.length; i++ ) {
console.log(temperatures[i]);
}
Ulyssa Sneed
8,894 Pointstotally worked!! Thanks
1 Answer
Peter Vann
36,427 PointsHi 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
36,427 PointsMy bad...
I just saw the follow-up comments right after I answered!?! LOL
Mike Mike
Full Stack JavaScript Techdegree Student 10,055 PointsMike Mike
Full Stack JavaScript Techdegree Student 10,055 PointsWhoa you got an infinite loop try i= 0 and i < temperature.length should work