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 trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Iterating through an Array

Conner Williams
PLUS
Conner Williams
Courses Plus Student 3,305 Points

how do i log the numbers correctly in this exercise?

i am getting an error saying that the numbers are not logged in the correct order and i cannot figure out how to solve that problem.

script.js
var temperatures = [100,99,90,80,70,65,30,10];
for (var i = 0; i < temperatures.length; i += 1); {
console.log(temperatures[i]); }
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Conner,

Your problem is an errant semicolon between your condition of the for loop and the opening brace. Remove that and your challenge should pass.

Cheers

Alex

Antonio De Rose
Antonio De Rose
20,885 Points
//the reason for the error in this code, is because of the non readability, and a syntax, could be a type

var temperatures = [100,99,90,80,70,65,30,10];
for (var i = 0; i < temperatures.length; i += 1); { // do you need semicolons, for loop starting
console.log(temperatures[i]); }//better this brace go down one level