5. For Loops Inside For Loops



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

var myPlaces = ["a", "b", "c"];
var friendPlaces = ["d", "a", "e"];
for(var i = 0; i < myPlaces.length; i++) {
  for(var j = 0; j < friendPlaces.length; j++) {
    if (myPlaces[i] == friendPlaces[i]) {


Oh my god. facepalm

Just realised my mistake and fixed it. Gosh, JS can be so intricate haha.

In the condition of the if statement, I changed '==' to '===' AND I changed 'friendPlaces[i]' to 'friendPlaces[j]'.


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