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 trialscott Walker
2,506 Pointssurely aslong as the array starts printing from position 0 this should work?
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.
is my error , im not sure how its skipping an item on the array .
var temperatures = [100,90,99,80,70,65,30,10];
for ( var i= 0 ; i < temperatures.length ; i += 1){
console.log(i);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
1 Answer
KRIS NIKOLAISEN
54,972 PointsYou are logging i when you should be using i as an index to log the temperatures
var temperatures = [100,90,99,80,70,65,30,10];
for ( var i= 0 ; i < temperatures.length ; i += 1){
console.log(temperatures[i]);
}
garryl torres
1,090 Pointscan someone explain as to why adding the array [i] after temperatures in the console.log works and not just console.log(temperatures) by itself? To me, it seems like it would just log the index value (0,1,2,3, etc..) and not the values ( 100, 90, 99, etc..). confused
i was overthinking it and thought that we would have to create a separate variable such as 'list' like the previous video. thanks in advance!
Cheo R
37,150 PointsCheo R
37,150 PointsLooks like you need to sort your array before logging them out.