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 Oswald
5,969 Pointsout of ideas
Im not sure what I am missing in this code for it to pass
var temperatures = [100,90,99,80,70,65,30,10];
for(var i = 0; i>= temperatures.length; i +=1 ) {
console.log(temperatures[i])
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Travis Batts
4,031 PointsAlmost got it Justin. Looks like your boolean is backwards.
var temperatures = [100,90,99,80,70,65,30,10];
for(var i = 0; i <= temperatures.length; i +=1 ) { console.log(temperatures[i]) }
This looks like what you're after.
So change your >= to <=.
jeffrey bachynski
5,179 PointsHint: Is i greater than or equal to temperatures.length?
Travis Batts
4,031 PointsWell In my code I place "I" as being "less" than temperatures.length. In your code you have "I" as being "greater than".
var i = 0, so "I" can not be greater than temperatures.length in this case.
Justin Oswald
5,969 PointsThank you it seems the error is always something obvious that only I cannot see haha
Justin Oswald
5,969 PointsThank you it seems the error is always something obvious that only I cannot see haha
jeffrey bachynski
5,179 Points@Travis, I can see that you wrote it correctly. I was trying to give Justin a hint. We both answered at about the same time. Sorry for the confusion.
Travis Batts
4,031 Points@Jeffrey. Lol I honestly did not pay attention to the names at all. I thought you were the OP (nor did I fully read the response). That is my mistake sorry about that.
Justin Oswald
5,969 PointsJustin Oswald
5,969 PointsThank you it seems the error is always something obvious that only I cannot see haha