Task completed - #4482
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because a core requirement is missing and it blocks correct functionality. In src/herbivoresAndCarnivores.js, the Carnivore.bite method does not verify the target is a Herbivore; per the task, it should not work on another carnivore. Please add a type check like if (!(animal instanceof Herbivore)) return; before proceeding with the bite logic so carnivores cannot bite carnivores. Additionally, the CI is failing due to a lint error: there is an unexpected console statement at or around line 44 (ESLint no-console). Remove that console call or suppress it with // eslint-disable-next-line no-console if truly necessary. After adding the instanceof Herbivore guard and fixing the console lint issue, the feature should meet the requirements and allow the pipeline to proceed. Nice job handling the hidden state check; keep that logic alongside the new type guard.
✨ 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
|
|
||
| class Carnivore extends Animal { | ||
| // write your code here | ||
| bite(animal) { |
There was a problem hiding this comment.
The bite method should check if the incoming animal is an instance of Herbivore before proceeding. According to the task: 'The method does not work if it is another carnivore'. Add a check for animal instanceof Herbivore.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation correctly meets all the task requirements. The Animal, Herbivore, and Carnivore classes are properly structured with the required properties and methods. The bite method correctly implements the dual condition checking that the target is a Herbivore and is not hidden, using a single if statement as expected. Dead animals are properly filtered from Animal.alive, and the hide method correctly sets the hidden property without toggling. Great work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.