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 trialJoshua Harman
8,821 PointsCommunication Problem for this test specifically.....
So I keep receiving a communication error every time I go to input the answer for this test.. I'm not sure why, but I figured I'd say something.
Thanks for the hard work. This is an amazing course.
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>
4 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Joshua,
I think the challenge is timing out because you've created an infinite loop.
i + 1
doesn't change the value of i
You have to add 1 to i
and then store the result back in i
You could replace i + 1
with any of the following:
-
i = i + 1
long way to write it -
i += 1
addition assignment operator. A little shorter. -
i++
increment operator. This is the one you will probably most commonly see. Might not have been taught in the course though
jerry bremser
3,941 Pointscan you eleborate? is that entire code? if it is it seems youre missing an input option for the user. it never prompts anything at all. again im not 100% sure what the issue is if you could show whole code or lesson reqs.
Jason Anello
Courses Plus Student 94,610 PointsHi Jerry,
For future reference, usually a question about treehouse content will have a link to that piece of content over in the right column under "Related content".
In this case there's a direct link to the code challenge that this question is about. There you can review the challenge or test code if needed.
jerry bremser
3,941 Pointsbut wouldn't the var i=0 mean it can be anything between 0 and 0.9999999? by adding the +1 at the end im assuming he didnt mean to update the variable 'i' but to make it so 'i' can not be any lower than the number 1? does that sound right? just wondering before i look over it again
Jason Anello
Courses Plus Student 94,610 PointsHey Jerry,
This mdn page will tell you what each part of the for
loop is for: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
Joshua Harman
8,821 PointsJASON THAT WAS IT!!!! THANK YOU SOOOOOO MUCH!!!!!!!!!!
Jason Anello
Courses Plus Student 94,610 PointsYou're welcome.