5. for loops inside of for loops


#1

https://www.codecademy.com/courses/learn-javascript/lessons/loops/exercises/for-loops-iii?action=lesson_resume&link_content_target=interstitial_lesson

I don't understand. Even the given code won't be accepted by the last step
Error message:

"Did you write an if/else statement inside the second for loop?"

var myPlaces = ['Brazil', 'Mexico', 'Australia'];
var friendPlaces = ['Italy', 'Paris', 'Brazil'];

for (var i = 0; i < myPlaces.length; i++) {
    console.log(myPlaces[i]);
  
  for (var j = 0; j < friendPlaces.length; j++) {
        console.log(friendPlaces[j]);
     if (myPlaces[i] === friendPlaces[j]) 
    {
    			console.log('Match: ' + myPlaces[i]);
		}
  }
  }


#2

if statement should be on teh same indentation level as console.log()


#3

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