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

How do I log the numbers from 100 to 10.

I thought changing the < and > sign that it would work but it is not. Can anyone explain what is going wrong.

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

1 Answer

Steven Parker
Steven Parker
231,275 Points

There's nothing named "print" defined in this code, and you won't need any HTML tags. You also don't need to create a function.

Just use "console.log" inside the loop to directly log each item from the "temperatures" array.

And check the limit test being used in the conditional clause of the "for" loop.

I did what you told me and i still seem to be getting the answer incorrect how do I upload my new answer to show you

Steven Parker
Steven Parker
231,275 Points

You can paste in your code, just use "markdown" formatting. There's a pop-up "cheatsheet" below, or you can watch this video on code formatting.