Small question with gas attack

hello, I did pass the level gas attack, but there is a couple of “preloaded lines” that I do not understand:

// Use the cannon to defeat the ogres.
var cannon = hero.findNearest(hero.findFriends());
// The cannon can see through the walls.
var enemies = cannon.findEnemies();

what is this “cannon” variable? how can you set it to find ennemies? I don’t really understand what’s going on in this part of the code… :sweat:

cannon is hero.findNearest findFriends so canon is nearest friend.

then you ask your friend to find his enemy
enemies = cannon.findEnemies

so you find nearest friend and ask him to search enemies

1 Like

Thank you very much! I understand perfectly now :slight_smile:

1 Like