Skip to content

Commit 35f6dbd

Browse files
correct
1 parent d0e6884 commit 35f6dbd

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/herbivoresAndCarnivores.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ class Carnivore extends Animal {
3232
animal.health -= 50;
3333

3434
if (animal.health <= 0) {
35-
const index = Animal.alive.indexOf(animal);
36-
37-
Animal.alive.splice(index, 1);
35+
Animal.alive = Animal.alive.filter((a) => a.health > 0);
3836
}
3937
}
4038
}

0 commit comments

Comments
 (0)