Writing Your Own Functions
Now that you have refactored some of the bounty board’s logic into a function, you can proceed as planned to implement a new function that will read the bounty board. Below your main function, define a function called readBountyBoard that takes no arguments. Make its visibility private. readBountyBoard should have no return statement, but it should print the contents of the bounty board.
readBountyBoard will also need to have access to the playerLevel variable. Although you could pass it in as an argument, moving playerLevel to a file-level property will make your new function easier to call. When you move the variable declaration, also promote Madrigal from level 4 to level 5 by changing the value of playerLevel ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access