A club has the following members:
First name | Last name | Year joined |
---|---|---|
Jon | Snow | 2000 |
Arya | Stark | 2013 |
Tywin | Lannister | 1987 |
- Write a function that takes a first name, a last name and a joining year parameter, and returns a message as a string that congratulates a member for their membership anniversary. E.g. Jon Snow receives the message "Dear Jon Snow, thank you for being a member for 21 years!"
- Add a comment above your function to explain what it does.
- Call your function with each member of the club and log the results to the console.
- What's the difference between a
return
andconsole.log
? - When would you choose to use functions over the way we have been scripting so far?
As a gift to long-term members, the club offers a 10% discount from the membership fee.
- Write a function that takes a price parameter and returns the input price reduced by 10%.
- Call your function with the annual membership fee of £100 and the monthly membership fee of £10 and log the results to the console.
- How would you modify the function if the annual membership fee is reduced by 10% but the monthly membership fee is only reduced by 5%?