Solution: Extension Properties
In this section, you will explore the solution for the extension properties' challenge.
We'll cover the following
Solution: Extension Properties
Let’s revisit the problem stated in the previous challenge.
You have a guest list
['Aman', 'Amit']
. Each guest can bring one additional person along with them. Implement an extension propertymaxGuests
onList
to calculate the maximum number of guests.
The problem reads that each guest can bring one person. By this summation, it is possible to have a maximum of two guests per entry on the guest list. By multiplying the size of guestList
by 2 we will have the maximum number of guests that are allowed to the event.
In addition, calling maxGuests
on guestList
will provide the maximum number of guests.
Check out the implementation in the code snippet below.
Get hands-on with 1400+ tech skills courses.