Nested loops


I am not getting, which function find the matching element in friendsPlaces and myPlaces?


actually including the code or exercise url makes work a lot easier for the helping side, nowe we have to either guess what the code looks like, or find the exercise manually (there are 2 javascript courses)

well, i guess given you have nested loops (like title suggested), for each value used by outer loop, the inner loop iterates over all its values. So lets say both arrays have 5 elements in them, you iterate the array with the inner loop 5 times (for each value used by outer loop), this allows you to compare all values


Mean the loop will be moving on until it does not find an equal element?


how is this not an obvious hint? Please explain so i can do it better next time

no, it means for each value in myPlaces array, it will loop over all places in friendsPlaces.

lets say we have this:

myPlaces = ['a', 'b', 'c']
friendPlaced ['d','e','f']

we get the following comparisons:

a d
a e
a f
b d
b e
b f
c d
c e
c f

if you just had provided your code, i could have inserted console.log statements to show you, but given this was too much to ask, i recommend you do it yourself. This allows you to see what your code does


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