What we want to have happen right now is that if I say “open”, the chest lid opens. If it happens to already open, we want it to do nothing. For that, we can use the keyword
return, which stops the function early.
- Add an if-statement that checks if the value of
“open”AND the chest’s
isOpenproperty is already true.
- Send a message to the console to notify yourself that that happened.
- Use return to have the function stop there.
- Do the same in an else-if-statement if the value of
“close”and the chest’s
isOpenproperty is not true.