I have the following globals js module:

```
var globals = (function (){
   var selectedReportPeriodId = 2;
   return{
      SelectedReportPeriodId : selectedReportPeriodId 
   };
})();

```

My code sets SelectedReportPeriodId based on the report period option that the user selects. I want to add a js getter to this module which would functionally work like this:

```
function IsCurrentReportPeriod()
{
   return selectedReportPeriodId === 1
}

```

I'd like downstream code to call the getter like this:

```
if(globals.IsCurrentReportPeriod)
{
   //do this
}

```

What would be an elegant way to implement this as a getter in the js module above?

***UPDATE #1***

I tried to implement like this:

```
var globals = (function (){

   var selectedReportPeriodId;

   return{
      SelectedReportPeriodId : selectedReportPeriodId,
      get IsCurrentReportPeriod() {
         return selectedReportPeriodId == 1;
      }
   };
})();

```

I'm setting globals.SelectedReportPeriodId = 1 in previous code. I also set a breakpoint in a method and set a watch of globals.SelectedReportPeriodId which returns 1. However, globals.IsCurrentReportPeriod returns false in the line below this code so my getter as defined does not seem to be working as expected. Any suggestions?

***UPDATE #2***

selectedReportPeriodId is initialized with a value of 2. I'm guessing that this may be a reason why the getter sees selectedReportPeriodId = 2 instead of 1 even after the updated value is set. What is a good solution for this? Should I make a getter for selectedReportPeriodId as well which does some conditional logic as opposed to initializing with a hard-coded value?