Check out a free preview of the full Build a Game Project: Feed-A-Star-Mole course:
The "Fed Status" Lesson is part of the full, Build a Game Project: Feed-A-Star-Mole course featured in this preview video. Here's what you'd learn in this lesson's course:

Brian assigns a status of "fed" for hungry moles that are clicked, such that it shows the mole eating a worm.

Get Unlimited Access Now

Transcript from the "Fed Status" Lesson

[00:00:00]
>> Brian Holt: Now we have this new status up here that we need to take care of. Which is, what happens after a moles fed? What's its next state, after we show the happy face for a mole, what should I do next? Yeah, so isn't it the same thing as sad, in the sense of like, it does the exact same action afterwards, right?

[00:00:32]
It goes to leaving, you show the same leaving you get the same interval. So we can actually just reuse this case right here, right? So, we can just say case fed right there. And now we can just reuse all the logic here, which is quite nice. So now, hopefully.

[00:01:01]
>> Brian Holt: mole.node children is undefined.
>> Brian Holt: Class list.
>> Brian Holt: So that's curious, I wonder if, Inspect Element.
>> Brian Holt: So $0.
>> Brian Holt: So x.remove. This was a very subtle bug. So, class list has a method called remove to remove a class. A DOM node also has a method called remove which removes itself from the DOM.

[00:01:47]
So I was calling a different remove method then I was actually anticipating I was going to call. So that's why it was coming up as undefined. That's a tough one. That's pretty subtle. Normally if you called the function on something, you would not expect to accidentally have a same method called the same thing.

[00:02:08]
Okay, so now save,refresh, this should just work the way we were anticipating it.
>> Brian Holt: So you can see there it's fed and then it goes away. This gets fed and it goes away.
>> Brian Holt: That's all working, right? Good stuff?