Having Trouble With JavaScript Loops


For some reason I'm getting a result saying "undefined" when I run this code. It's supposed to go through each item in myPlaces and log out each place. Can anyone let me know if there's something wrong with my code?

var myPlaces = ['Utah', 'Dallas', 'Chicago'];
var friendPlaces = ['Chicago', 'Texas', 'Virginia'];

for (var i = 0; i < myPlaces.length; i++); {


Do you mean this output in the console?



Yes. I figured it out it was a simple syntax error. I had to remove the semicolon that was after my for loop


Ah, yes. I was sure you would see that! The list is printing okay, then?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.