Skip to content

task witch class - #4481

Open
notbelievable wants to merge 2 commits into
mate-academy:masterfrom
notbelievable:develop
Open

task witch class#4481
notbelievable wants to merge 2 commits into
mate-academy:masterfrom
notbelievable:develop

Conversation

@notbelievable

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/herbivoresAndCarnivores.js Outdated
Comment on lines +32 to +34
if (target.health <= 0) {
const indT = Animal.alive.indexOf(target);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants