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 trialjames mchugh
6,234 PointsI can't seem to get this one
It seems that I forgot how to do this. I've reviewed the video's and can't seem to get it. I took a break for 2 weeks while I moving into a new house and forgot a lot of things.
var temperatures = [100,90,99,80,70,65,30,10];
var listTemps = 'temperatures';
for (var i = 0; i < temperatures.length; i += 1) {
console.log('listTemps');
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
1 Answer
matth89
17,826 PointsYou're calling your var names inside quotation marks, which is turning them into strings, rather than referencing the variables. Also, as Brendon said, you're missing a closing curly brace on the end of your for loop.
james mchugh
6,234 PointsI added the closing bracket and removed the quotation marks, and now it says I'm not logging the temperatures in the right order. Bummer! The items in the array weren't logged out in order. Your should log all the temperatures in order, starting at 100 and ending at 10. That's the message I get.
matth89
17,826 PointsThat makes sense, I didn't look closely enough at your code. Remove your listTemps var altogether, and then inside console.log call temperatures with an index of "i", like so: temperatures[i].
Inside your for loop "i" starts with an index of 0, and is incremented by 1 on each pass. So, on each loop through it will grab the next value inside your list. right now listTemps holds your entire temperature list, so calling that returns the entire list at once. Hope this helps.
james mchugh
6,234 PointsThanks Matt, that worked.
Brendon Butler
4,254 PointsBrendon Butler
4,254 PointsI'm not sure what exactly the issue you're having is, but it looks as if you're missing a closing bracket
}
for your "for loop"