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 trialRyan Wikle
5,774 PointsI am getting an error that says “undefined is not an object”. Which part of the code is that referring to?
const temperatures = [100, 90, 99, 80, 70, 65, 30, 10];
for( let i = 0 ; i> temperatures.length; i++) {
console.log(temperatures[i]);
}
3 Answers
Bert Witzel
Full Stack JavaScript Techdegree Graduate 27,918 PointsSometimes these quizzes aren't the best at identifying what the problem is, in your case you have i > temperatures.length
when it should be i < temperatures.length
:
const temperatures = [100, 90, 99, 80, 70, 65, 30, 10];
for (let i = 0; i < temperatures.length; i++) {
console.log(temperatures[i]);
}
Ryan Wikle
5,774 PointsThank you for catching that. However I am still getting the same error message.
Bert Witzel
Full Stack JavaScript Techdegree Graduate 27,918 PointsHmm, I just posted it in the challenge again and I passed it okay. Make sure to not paste const temperatures
again if you are copying and pasting the code above, that's the only thing I can think might be the problem.
Ryan Wikle
5,774 PointsMy code worked when I tested it outside of the challenge. And it was finally accepted after I refreshed the page and restarted the challenge. I think I was having an issue with the tree-house site not my actual coding.