It won't even show an error on the console

let myPlaces = [‘home’, ‘rome’, ‘The dome’]
let friendPlaces = [‘Home’, ‘Espana’, ‘chicago’]

for (let myPlacesIndex = 0; myPlacesIndex < myPlaces.length; myPlacesIndex++) {

for (let friendPlacesIndex = 0; friendPlacesIndex < friendPlaces.length; friendPlacesIndex++) {
if (myPlaces[myPlacesIndex] === friendPlaces[friendPlacesIndex]) {
console.log('Match: ’ + myPlaces[myPlacesIndex]);

Nothing is being logged to the console, and no error is appearing.

This will also not print anything.

if (false) {

If your code is supposed to print something, then you’ll need to review what events should lead up to that.
For example, in my piece of code here there’s a condition for executing the code that will print something, and it’ll need to be true, but is not, so if I change false to true I’ll get something to print. In your case you’ve got loops, you’d need to make sure that iterations happen, and you’ve got a condition, so you’d need to make sure that turns true during at least one iteration

1 Like

Or to be more direct, ‘home’ does not equal ‘Home’ so you aren’t ever getting a match, so it never prints. Change one to match the other, and it should work as expected.

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