Develop - #4484
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because there is a critical blocker in the bite logic that violates the task requirements. In src/herbivoresAndCarnivores.js lines 27–28, the bite method only checks herbivore.hidden === false and does not verify the target is actually a Herbivore. The requirement states the bite should not work on other carnivores, so relying on hidden being undefined is incorrect and could allow biting non-Herbivore objects with hidden: false.
Please fix the bite condition to explicitly ensure the target is a Herbivore and not hidden within a single if, for example: if (herbivore instanceof Herbivore && herbivore.hidden === false) { ... }. This aligns with the requirement to prevent carnivores biting other carnivores and addresses [CHECKLIST ITEM #1 guidance about clear conditions]. Also ensure health reduction by 50 and any death handling logic integrates with Animal.alive if applicable.
What you did well: using filter where appropriate and implementing hide to set hidden = true without toggling. After adding the instanceof Herbivore check and verifying death removal behavior, this should meet the core requirements. Keep it up—this is a small, targeted fix to make your solution robust.
✨ 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
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]
If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.
Address review feedback: bite() relied on `hidden` being undefined for carnivores, which would also let any object with `hidden: false` be bitten. Make the type check explicit with `instanceof Herbivore`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution correctly implements all required functionality. The Animal base class properly initializes health (default 100) and name, Herbivore extends Animal with a working hide method, and Carnivore's bite method correctly checks both instanceof Herbivore and hidden === false status before reducing health by 50. The implementation uses filter to remove dead animals from the Animal.alive array as specified. All checklist items are satisfied and no issues were found.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.