task witch class - #4481
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation correctly handles the core functionality—dead animals are being removed from the Animal.alive array. However, there is a checklist violation that needs to be addressed. According to checklist item #1, you should use the filter method instead of indexOf + splice for removing dead animals (lines 32-34). While both approaches work functionally, using filter is more idiomatic and avoids mutating the original array directly. To fix this, replace the current indexOf + splice logic with a filter call that returns all animals except the one being removed. This will align your code with the checklist requirement while maintaining the same behavior.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| if (target.health <= 0) { | ||
| const indT = Animal.alive.indexOf(target); | ||
|
|
There was a problem hiding this comment.
Checklist item #1 violation: Use Array's filter method instead of indexOf + splice to remove dead animals from the Animal.alive array.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution. You implemented the Animal base class with name and default health = 100, the Herbivore with a working hide() method, and the Carnivore with a bite() method that correctly checks the target is a Herbivore and not hidden before reducing health. You also correctly remove dead animals (health <= 0) from Animal.alive using filter, which satisfies the core functionality. No critical blockers were found, and all required behaviors are present and functionally sound. Nice work keeping the logic clear and aligned with the requirements. If you want to go further, consider adding small guards or messages for invalid targets to improve developer feedback, but this is not required.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.