Skip to content

solution - #3858

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

solution#3858
bebelekele wants to merge 2 commits into
mate-academy:masterfrom
bebelekele:develop

Conversation

@bebelekele

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

Thanks for your hard work! 😊 There's just one critical issue left: you need to use the filter method to remove dead animals from the Animal.alive array, instead of forEach and splice. Please update your code to use Animal.alive = Animal.alive.filter(animal => animal.health > 0); after any health reduction. Once that's fixed, your solution will be perfect! Keep going—you’re almost there! 🚀


✨ 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 +31 to +35
Animal.alive.forEach(function (animal, index, arr) {
if (animal.health <= 0) {
arr.splice(index, 1);
}
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: Removing dead animals from the Animal.alive array using forEach and splice can cause elements to be skipped and is not the preferred method. According to the checklist and override instructions, you should use the filter method to remove animals with health less than or equal to 0. Please update this logic to use Animal.alive = Animal.alive.filter(animal => animal.health > 0);.

@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

Great job! 🎉 Your implementation in src/herbivoresAndCarnivores.js fully meets all the task requirements and constraints. The class hierarchy is correct, and both the hide and bite methods behave exactly as specified. You correctly use a single if statement in bite to check both instanceof Herbivore and !hidden, and you remove dead animals from Animal.alive using the filter method, as required. The hide method only sets hidden to true without any toggling or extra logic. There are no unnecessary files, missing files, or broken functionalities.

All previous issues have been addressed, and your code is now clean, efficient, and adheres strictly to the requirements. No further changes are needed. Well done—keep up the great work! 🚀


✨ 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