Last active
March 1, 2016 14:41
-
-
Save jamesbaber/b05af6bbbb2b97b8bdcd to your computer and use it in GitHub Desktop.
Removing object from array depending on value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function IsDead( enemy ) { | |
if (enemy.health <= 0) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
function RemoveDead(enemy) { | |
var deadEnemies = enemys.find(IsDead); | |
for (enemy in deadEnemies) { | |
enemys.slice(enemys.indexOf(enemy), 1 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment