| 12345678910111213141516171819202122232425262728 |
- let restaurant = {
- name: 'Red Lobster',
- guestCapacity: 75,
- guestCount: 0,
- checkAvailability: function (partySize) {
- let seatsLeft = this.guestCapacity - this.guestCount
- return partySize <= seatsLeft
- },
- seatParty: function (guests) {
- this.guestCount = this.guestCount + guests
- console.log(`seating ${guests}, total is now ${this.guestCount}/${this.guestCapacity}.`)
- },
- removeParty: function(guests) {
- this.guestCount = this.guestCount - guests
- console.log(`${guests} leaving, total is now ${this.guestCount}/${this.guestCapacity}.`)
- }
- }
- // seatParty
- // removeParty
- restaurant.seatParty(72)
- console.log(restaurant.checkAvailability(4))
- restaurant.removeParty(5)
- console.log(restaurant.checkAvailability(4))
|