Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
REQUEST_CHANGES
Thank you for your hard work on this! Your implementation of the class hierarchy and method logic is solid, but there are critical blockers that must be addressed before approval:
Issues to Fix:
-
Incorrect Removal of Dead Animals from
Animal.alive- The requirements and checklist explicitly state that you must use the
filtermethod to updateAnimal.aliveand remove dead animals (those withhealth <= 0). - Currently, you are using
indexOfandspliceinside thecheckIfAlivemethod. This does not meet the requirement. - How to fix: Replace your removal logic with:
Do this wherever you need to remove dead animals from the array.
Animal.alive = Animal.alive.filter(animal => animal.health > 0);
- The requirements and checklist explicitly state that you must use the
-
Animal.aliveMay Contain Dead Animals- The removal of dead animals only happens when
checkIfAliveis called (e.g., afterbite). If an animal's health is set to 0 by other means, it may remain inAnimal.alive. - How to fix: Ensure that
Animal.aliveis always updated after any action that could cause an animal to die, not just afterbiteorcheckIfAlive.
- The removal of dead animals only happens when
Why this matters:
- These issues violate explicit checklist items and core requirements. They could cause your code to fail tests or behave incorrectly in edge cases.
Next Steps:
- Refactor your code to use
filterfor updatingAnimal.alive. - Make sure dead animals are always removed immediately after their health drops to 0 or below, regardless of how that happens.
Once you address these, your code should be fully compliant. You're very close—keep up the good work!
✨ 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
| const index = Animal.alive.indexOf(this); | ||
|
|
||
| if (index !== -1) { | ||
| Animal.alive.splice(index, 1); |
There was a problem hiding this comment.
This violates checklist item: 'The Animal.alive array must be updated using the filter method to remove dead animals (those with health <= 0).' You are using indexOf and splice instead of filter.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
All core requirements and checklist items are fully met. Your implementation of the Animal, Herbivore, and Carnivore classes is correct, uses ES6 class syntax, and handles all required behaviors such as hiding, biting, and maintaining the Animal.alive array with the filter method. There are no critical or blocking issues—everything functions as specified. Great job on a clean, efficient, and standards-compliant solution!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.