class Animal {
constructor(name, species, sex) {
this.species = species;
this.sex = sex;
this.name = name;
this.stomach = [];
}
eat(food) {
this.stomach.push(food);
}
poop() {
const randomAmount = Math.round(Math.random() * (this.stomach.length - 1));
let doggyBag = [];
for (var i = 0; i < randomAmount; i++) {
doggyBag.push(this.stomach.pop());
}
return doggyBag;
}
introduce() {
return `Hi, my name is ${this.name}. I'm a ${this.sex} ${this.species}.`;
}
}