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 Review Array Methods, Iterating and Two-Dimensional Arrays

Quiz

Quiz Question 2 of 6 Fill in the blank below. Choose the correct answer below: Skip Quiz Review Video Get Help Next Question The following code should print out each item in the array times, but there's one part is missing. Finish the code to log out each array item to the console:

var times = [ 1.22, 1.75, 2.10, 2.55 ];
for (var i=0; i < times.length; i += 1 ) {
 console.log(times[]); 
}

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Andrew,

What this question is missing is a tiny piece of code that makes the loop iterate through all the values in the times array.

var times = [ 1.22, 1.75, 2.10, 2.55 ];
for (var i=0; i < times.length; i += 1 ) {
 console.log(times[i]); 
}

If you see the way i is declared as an array variable called times.

This is referenced in your log to the console. So you put i in the empty array literal.

Hope this helps. :)

By the way I edited your post to include the correct markdown forum code so we could see it better. Have a look at the markdown cheatsheet for details. :) https://teamtreehouse.com/forum/quiz-8#