a) For making the hero say something, I create a dedicated variable
enemy1 = "Smasher" distance1 = hero.distanceTo(enemy1) hero.say(distance1)
This is the method used in the level’s sample code.
b) I don’t create an extra variable but just use the function for determining its value instead:
enemy2 = "Gort" hero.say(hero.distanceTo(enemy2))
Both ways accomplish the task, but which is preferable (under what circumstances), and why?
Btw this is the task from range finder level