The console is a place designed to run small one-use scripts or to test your code for Postfunctions, Listeners, Repo, etc. With that in mind, when you run code you need to give a Issue as a context if you want to test your script in that issue’s context. To set an issue as context, just do the following:
issue = Issue("Your Issue Key")
Then you can access all the Issue normal capabilities.