I have the below code where I am loading values to the array usageCategory in an inline function. But when I try to print the values outside this function, nothing gets printed. 

```
getAllUsageCategoryElements(){

        var usageCategory: string[] =  [];

        var that=this;

        // extract all the droplist elements and put into an array so that I can validate them from another page.
        this.addAdditionalCostDialogue.usageCategoryDropListContainer.all(by.tagName('li')).all(by.tagName("span")).each(function (element, index) {
            element.getText().then(function (text){

                 //console.log("printing directly " + text);
                // the above code works fine and prints all the drop list contains but when I try to add it to an array

                that.usageCategory.push(text);
            })
        });

        console.log("Size of the array is " + usageCategory.length);

        usageCategory.forEach(element => {
            console.log("Printing text " + element);
        });
    }

```

What am I doing wrong here? How can I access these array values outside the inline function? Any help would be much appreciated.