Small question with gas attack


#1

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:


#2

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


#3

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