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 trialJustin Olson
13,792 PointsChallenge assist please.
Good day all! Now, obviously, there is a problem with my code. I knew it was wrong when executed, but as it's early in the morning right now, and I'm recovering from an all day rock concert yesterday...my head isn't working properly. Anyways, the challenge asks for a for/while loop to be created to log the first item 100, to the last item 10. I just...can't get it. Please help put my tired head to rest.
var temperatures = [100,90,99,80,70,65,30,10];
for(var i = 0; i < temperatures.length; i+=1);
console.log(temperatures);
2 Answers
Kristian Terziev
28,449 PointsFirst, I formatted your code properly using the Markdown Cheatsheet you can access under the textarea you write your comment in.
Now for your question - When using for loop, you need to have a body. That is indicated by the curly brackets {}. You're missing those (you've put a semicolon in their place). Also when accessing elements of an array you need to specify which element you want by using it's index. Therefore to complete the challenge, your code should look something like this:
for (var i = 0; i < temperatures.length; i += 1) {
console.log(temperatures[i]);
}
jennifer ray
7,875 PointsHi Kirstian,
I just read your reply as I was trying to make the same code challenge more complicated than it was. I had the basic idea but I was trying to make the last i a minus to make the code count down from 100 to 10. does i = 0 is that because 0 is the 1st item in list? then 1, 2, 3 ect. Jen