Skip to content

Instantly share code, notes, and snippets.

@jamesbaber
Last active March 1, 2016 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesbaber/b05af6bbbb2b97b8bdcd to your computer and use it in GitHub Desktop.
Save jamesbaber/b05af6bbbb2b97b8bdcd to your computer and use it in GitHub Desktop.
Removing object from array depending on value
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