So, I don’t really know how to use the “push” method so I just did hero.push() and it’s giving me an error that says the hero has no method “push” and I don’t know what to do with it!! Here is my code:
// That's a lot of Yaks!
// If you are to survive, you'll need to filter out Yaks...
function removeByType(enemies, excludedType) {
var tempArray = [];
// Go through each enemy and check to see if its type is excludedType.
for(var i = 0; i < enemies.length; i++) {
// If it isn't, 'push' it onto the array.
let enemy = hero.findNearestEnemy();
if (enemy.type != "sand-yak") {
hero.push(enemy);
}
}
return tempArray;
}
while(true) {
// Find the enemies!
var enemies = hero.findEnemies();
// Remove those pesky Yaks.
enemies = removeByType(enemies, "sand-yak");
var enemy = hero.findNearest(enemies);
// Now... 'remove' those enemies.
if(enemy) {
hero.attack(enemy);
}
}