5. for loops inside of for loops

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/learn-javascript/lessons/loops/exercises/for-loops-iii?action=lesson_resume&link_content_target=interstitial_lesson
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
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]);
		}
  }
  }


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

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